https://pintia.cn/problem-sets/994805260223102976/problems/994805277163896832
#include <iostream>
using namespace std;
int main(){
int n, score[1002] = {0}, tmp1, tmp2 = 0;
cin >> n;
for(int i = 0; i < n; i++){
int a, b, c;
scanf("%d-%d %d", &a, &b, &c);
score[a] += c;
}
for(int i = 0; i < 1001; i++){
if(score[i] > tmp2){
tmp2 = score[i];
tmp1 = i;
}
}
cout << tmp1 << " " << tmp2;
return 0;
}
本文展示了一个使用C++编写的程序,该程序用于解析输入的竞赛成绩,并找出最高得分及对应的选手编号。通过逐行读取输入并解析每条记录中的数据,最终输出获得最高总分的选手编号及其分数。
3154

被折叠的 条评论
为什么被折叠?



