刚开始有点担心超时,但是发现其实可以边输入边攒数据
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=10100;
int main()
{
int n,ans,total=-1;
int hashnum[maxn]={0};
cin>>n;
for (int i=0;i<n;i++)
{
int team,member,score;
scanf("%d-%d %d",&team,&member,&score);
hashnum[team]+=score;
if (hashnum[team]>total)
{
ans=team;
total=hashnum[team];
}
}
printf("%d %d",ans,total);
}