题目
注意点:
(1)这里要提前给数组赋好初值0,否则加起来会有问题。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
int school[100000]={0};
int i,n,s,j;
scanf("%d",&n);
school[0]=0;
int tem=0,tep=0;
j=n;
while(j--){
scanf("%d%d",&i,&s);
school[i]+=s;
}
for(j=1;j<=n;j++){
if (tep<school[j]){
tem = j;
tep =school[j];
}
else continue;
}
printf("%d %d",tem,tep);
}