解题代码
#include<cstdio>
#include<unordered_map>
using namespace std;
int main()
{
int num, team, id, score, max = 0;
scanf("%d", &num);
unordered_map<int, int> m;
for (int i = 0; i < num; i++) {
scanf("%d-%d %d", &team, &id, &score);
m[team] += score;
}
for (auto x : m) {
if (x.second > max) {
team = x.first;
max = x.second;
}
}
printf("%d %d", team, max);
return 0;
}
测试结果
问题整理
1.哈希。