CF2A.Winner

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:64MB

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 m) at the end of the game, than wins the one of them who scored at least m 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.

俄罗斯贝尔兰德流行的纸牌游戏“贝尔洛金”(Berlogging)的获胜者按以下规则确定:若游戏结束时仅有一名玩家得分最高,则该玩家获胜。若有多名玩家并列最高分,则情况变得复杂。在每一轮中,每位玩家会获得或失去一定数量的分数。整个游戏过程中,每轮的得分记录格式为“姓名 分数”,其中“姓名”为玩家姓名,“分数”为该轮所获分数(整数)。若“分数”为负数,则表示该玩家在本轮失利。因此,若游戏结束时有两名或以上玩家得分并列最高(设该最高分为 mm),则其中最先在某一轮结束后累计得分达到或超过 mm 分的玩家获胜。初始时,每位玩家的分数均为 00。题目保证:游戏结束时至少有一名玩家的分数为正数。

输入格式

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

第一行包含一个整数 $ n (( 1 \leq n \leq 1000 $),表示进行的轮数。随后是 $ n $ 行,按时间顺序给出各轮的信息,格式为“姓名 得分”,其中姓名是由长度为 $ 1 $ 至 $ 32 $ 的小写拉丁字母组成的字符串,得分为介于 $ -1000 $ 到 $ 1000 $(含端点)之间的整数。

输出格式

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

输入解题思路,AI测评打分。不知道怎么写?

首页