笔记精选

笔记精选

http://www.nowcoder.com/questionTerminal/60a9ce2437694f4f81d6ed94a0c265e9

记相应编号对应的点赞数为:,其对应的最大点赞总数为:,即:

   
   
   
   


      
由于,对于任意 得:

代码,如下所示:

#include <iostream>
 using namespace std;


 int main(int argc, char* argv[]) {
     int n = 0;
     while(cin >> n) {
         int tmp_sum_likes = 0, max_sum_likes = 0;
         int tmp_num = 0, min_num = 0;

         int likes;
         while(n--) {
             cin >> likes;

             int sum_likes = tmp_sum_likes + likes;
             int num = tmp_num + 1;

             tmp_sum_likes = max_sum_likes;
             tmp_num = min_num;

             if(sum_likes > max_sum_likes) {
                 max_sum_likes = sum_likes;
                 min_num = num;
             }
         }

         cout << max_sum_likes << " " << min_num << endl;
     }
     return 0;
 }
全部评论

相关推荐

球球别再泡了:坏,我单9要了14
点赞 评论 收藏
分享
评论
2
收藏
分享
牛客网
牛客企业服务