#include<bits/stdc++.h>
using namespace std;
const int N=1e6+100;
typedef pair<int,string> pill;
map<string,int> cnt;
queue<pill> q;
string t[N];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
string s;
int w;
cin>>s>>w;
cnt[s]+=w;
q.push(make_pair(cnt[s],s));
t[i]=s;
}
int res=-N;
for(int i=1;i<=n;i++)
res=max(res,cnt[t[i]]);
while(!q.empty())
{
if(q.front().first==res&&cnt[q.front().second]==res)
{
cout<<q.front().second;
break;
}
q.pop();
}
return 0;
}
比如:
4
a 5
a -3
b 5
a 3
输出:a
还有:
8
d 13
c 12
a 1
a 1
a 1
b 10
d -12
a 9
输出:c
这些我都可以啊,还有哪里不行呢????