code1:
#include<stdio.h>
int p[100055],q[100055],k[100055];
int main(){
int n;
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&p[i]);
scanf("%d",&q[i]);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(p[i]==p[j])
k[i]=q[i]+q[j];
}
}
int Mi=-134567;
int Locate;
for(i=0;i<n;i++){
if(k[i]>Mi){
Mi=k[i];
Locate=i;
}
}
printf("%d %d",Locate+1,Mi);
return 0;
}
code2:
#include<cstdio>
const int maxn=100010;
int school[maxn]={0};
int main(){
int n,ID,score;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&ID,&score);
school[ID]+=score;
}
int k=1;
int MAX=-1;
for(int i=1;i<=n;i++){
if(school[i]>MAX){
MAX=school[i];
k=i;
}
}
printf("%d %d",k,MAX);
return 0;
}