提交代码:
1 #include <stdio.h> 2 3 //定义常量 宏定义(宏替换) 4 #define maxn 100010 5 6 int school[maxn]={0}; 7 8 int main(){ 9 10 int n,schID,score; 11 scanf("%d",&n); 12 int i; 13 for(i=0;i<n;i++){ 14 scanf("%d%d",&schID,&score); 15 school[schID]+=score; 16 } 17 int k=1,MAX=-1; 18 for(i=1;i<=n;i++) { 19 if(school[i]> MAX) { 20 MAX=school[i] ; 21 k=i; 22 } 23 } 24 printf("%d %d ",k,MAX); 25 return 0; 26 }