###### Johnbug

It's too late to apologize, it's too late～

###### CF 2A Winner

#include <iostream>
#include <algorithm>
using namespace std;

struct P
{
string name;
int s;
}p1[1010],p2[1010];
bool cmp(P a,P b)
{
return a.s > b.s;
}
int main()
{
int n,i,j,k,k1;
P tmp;
while(cin>>n)
{
k = 0;k1 = 0;
for(i = 0;i < n;i ++)
{
cin>>tmp.name>>tmp.s;
for(j = 0;j < k;j ++)
{
if(p1[j].name == tmp.name){ p1[j].s += tmp.s;p2[k1].name = tmp.name;p2[k1++] = p1[j];break;}
}
if(j == k) {p1[k++] = tmp;p2[k1++] = tmp;}
}
sort(p1,p1+k,cmp);
int  l = p1[0].s;
for(i = 0;i < k1;i ++)
{
if(p2[i].s >= l)
{
for(j = 0;j < k;j ++)
{
if(p1[j].name == p2[i].name&&p1[j].s == l)
{
cout<<p1[j].name<<endl;
i = k1;
break;
}
}
}
}
}
}


#include <iostream>
#include <map>
#include <string.h>
#include <algorithm>
using namespace std;
int score[1010];
map<string, int> p1,p2;
string name[1010];
int main()
{
int n,i,j;
while(cin>>n)
{
int m = 0;
for(i = 0;i < n;i ++)
{
cin>>name[i]>>score[i];
p1[name[i]] += score[i];
}
for(i = 0;i < n;i ++)
if(p1[name[i]] > m) m = p1[name[i]];
for(i = 0;i < n;i ++)
{
p2[name[i]] += score[i];
if(p2[name[i]] >= m&&p1[name[i]] == m)
{
cout<<name[i]<<endl;
break;
}
}
}
}


#### CF-2A Winner(water)

2018-02-02 19:21:46

#### Codeforces 2A ：winner

2015-06-14 20:12:41

#### Codeforces 2A Winner (map运用)

2016-06-07 16:04:49

#### cf 2a Winner

2015-10-24 17:53:06

#### CodeForces 2A - Winner（模拟）

2014-10-27 19:26:15

#### 2A - Winner

2015-01-23 17:10:23

#### code forces 2A Winner

2014-03-24 20:53:19

#### codeforces - 2A - Winner

2017-03-18 01:33:49

#### Codeforces Round #2A Winner

2014-07-20 14:41:23

#### codeforce 2A Winner

2012-11-08 01:05:50

CF 2A Winner