代码
#include <iostream>
#include <map>
using namespace std;
int main() {
int n;
scanf("%d", &n);
map<int, int> m;
int championNum = 0;
int championScore = 0;
for(int i=0; i<n; i++) {
int team, member, score;
scanf("%d-%d %d", &team, &member, &score);
if(m[team]) {
m[team] += score;
} else {
m[team] = score;
}
if(m[team]>championScore) {
championNum = team;
championScore = m[team];
}
}
printf("%d %d\n", championNum, championScore);
return 0;
}
注解
map的简单使用。