CF2A Winner
题解:
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
map<string,int> mp,mpp;
int n,a[100001],maxn=-99999999;
string s[100001],s1;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s[i]>>a[i];
mp[s[i]]+=a[i];
}
for(int i=1;i<=n;i++)
{
maxn=max(maxn,mp[s[i]]);
}
for(int i=0;i<=n;i++)
{
mpp[s[i]]+=a[i];
if(mp[s[i]]==maxn&&mpp[s[i]]>=maxn)
{
s1=s[i];
break;
}
}
cout<<s1;
return 0;
}