题目
思路
还是用数组存分数,下标为队伍的编号
代码
#include <iostream>
using namespace std;
int main(){
int cnt;
cin >> cnt;
int ID[1001] = {0};
int max = 0;
while(cnt){
--cnt;
string s;
int grade=0,id=0;
cin >> s >> grade;
id = stoi(s.substr(0,s.find_first_of('-',0)-0));
ID[id] += grade;
if(ID[id] > ID[max]) max = id;
}
cout << max << " " << ID[max];
return 0;
}
来源:CSDN
作者:yhjf456
链接:https://blog.csdn.net/qq_43705697/article/details/104312156