#include<cstdio> #include<set> usingnamespace std; int num[100010]={}; set<int> s; intmain(){ int n; scanf("%d",&n); int a,b; int cnt=0; for (int i = 0; i < n; ++i) { scanf("%d%d",&a,&b); num[a]+=b; s.insert(a); } int max=-1; int index=0; for (set<int>::iterator i = s.begin(); i != s.end(); ++i) { if (num[*i]>max) { max=num[*i]; index=*i; } } printf("%d %d\n", index,max); return0; }
Gitalking ...