A. Winner
A.获胜者
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test. 64 megabytes
每次测试的内存限制。64兆字节
input: standard input
输入:标准输入
output: standard output
产出:标准产出
The winner of the card game popular in Berland “Berlogging” is determined according to the fllowing rules. If at the end of the game there
博兰“博格”中流行的纸牌游戏的胜利者是根据滚烫的规则来确定的。如果在比赛结束时
is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players
只有一个球员拥有最多的积分,他就是赢家。如果这样的玩家数量增加的话,情况就变得更加困难了。
is more than one. During each round a player gains or loses a particular number of points. In the course of the game the number of points
不止一个。在每一轮中,一名球员获得或失去一个特定的点数。在比赛过程中得分
is registered in the line “name score”, where name is a player’s name, and score is the number of points gained in this round, which is
在“名称得分”行中注册,其中名称是球员的姓名,得分是在这一轮中获得的点数,即
an integer number. If score is negative, this means that the player has lost in the round. So, if two or more players have the maximum
整数如果比分是负数,这意味着球员在回合中输了。所以,如果两个或两个以上的玩家
number of points (say, it equals to m) at the end of the game, than wins the one of them who scored at least m points first. Initially each
在比赛结束时的积分数(例如,等于m),比他们中的一个先得至少m分的人要多。最初每个
player has 0 points. It’s guaranteed that at the end of the game at least one player has a positive number of points.
球员得零分。这是保证在游戏结束时,至少有一个球员有一个正数的分数。
Input
输入
The first line contains an integer numbern(1≤n≤1000), n is the number of rounds played. Then fllow n lines, containing the
第一行包含整数编号n(1≤n≤1000),n是播放的次数。然后松开n行,包含
information about the rounds in “name score” format in chronological order, where name is a string of lower-case Latin letters with the
有关按时间顺序排列的“名称分数”格式的查询信息,其中名称是由小写拉丁字母组成的字符串,其中
length from 1 to 32, and score is an integer number between -1000 and 1000, inclusive.
长度从1到32,分数是一个整数,介于-1000和1000之间。
Output
输出量
Print the name of the winner.
打印获胜者的姓名。
英语题太难读了,/(ㄒoㄒ)/~~
map<string,ll> a,c;
pair<string,int> b[1007];
int main()
{
int n;
cin>>n;
ll maxi=-1e9,maxs=100;
string maxn;
for (int i = 0; i < n; ++i) {
cin>>b[i].first>>b[i].second;
a[b[i].first]+=b[i].second;
}
for (auto it = a.begin(); it!=a.end(); it++)
{
if(it->second==maxi) maxs=100;
else if(it->second>maxi)
{
maxi=it->second;
maxn=it->first;
maxs=1;
}
}
c.clear();
for (int i = 0; i < n; ++i) {
c[b[i].first]+=b[i].second;
if(c[b[i].first]>=maxi&&a[b[i].first]==maxi)
{
cout<<b[i].first<<endl;
break;
}
}
return 0;
}