题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805289432236032
代码
#include <cstdio>
const int maxn=100010;
int school[maxn]={0};
int main(){
int N,schID,score,i,k=1,MAX=-1;
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d%d",&schID,&score);
school[schID]+=score;
}
for(i=1;i<=N;i++) {
if(school[i]>MAX){
MAX=school[i];
k=i;
}
}
printf("%d %d",k,MAX);
return 0;
}