记相应编号对应的点赞数为:,其对应的最大点赞总数为:,即:
由于,对于任意 得:
代码,如下所示:
#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; }