CF2A.Winner

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The winner of the card game popular in Berland "Berlogging" is determined according to the following 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 mm ) at the end of the game, than wins the one of them who scored at least mm points first. Initially each player has 0 points. It's guaranteed that at the end of the game at least one player has a positive number of points.

在 Berland 流行着纸牌游戏 Berlogging,这个游戏的赢家是根据以下规则确定的:

  1. 在每一轮中,玩家获得或失去一定数量的分数,在游戏过程中,分数被记录在 名称和得分 行中,其中名字是玩家的名字,得分是在这一轮中获得的分数。得分是负值意味着玩家失去了相应的分数。
  2. 如果在比赛结束时只有一名玩家分数最多,他就是获胜者。
  3. 如果两名或两名以上的玩家在比赛结束时都有最大的分数 mm ,那么其中首先获得至少 mm 分的玩家胜利。开始时,每个玩家都是 00 分。

保证在比赛结束时至少有一个玩家的分数为正。

输入格式

The first line contains an integer number nn ( 1<=n<=10001<=n<=1000 ), nn is the number of rounds played. Then follow nn lines, containing the 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.

第一行包含整数 nn,表示是游戏进行的的回合数。

2n+12 \sim n + 1 行,按照时间顺序输入 名称和得分 行的信息,其中名称是长度不大于 3232 的小写字母组成的字符串,分数的绝对值不大于 10001000

输出格式

Print the name of the winner.

输出获胜者的名称。

输入输出样例

  • 输入#1

    3
    mike 3
    andrew 5
    mike 2

    输出#1

    andrew
  • 输入#2

    3
    andrew 3
    andrew 2
    mike 5

    输出#2

    andrew
首页