#abc354b. B - AtCoder Janken 2
B - AtCoder Janken 2
Score : points
问题陈述
名 AtCoder 用户聚集在一起玩 AtCoder RPS 2。第 名用户的用户名是 ,他们的评分是 。
AtCoder RPS 2 的玩法如下:
- 将数字 按用户名的字典顺序分配给用户。
- 设 为 名用户的评分之和。分配到数字 的用户是获胜者。
打印获胜者的用户名。
什么是字典顺序?
字典顺序,简单来说,就是“单词在字典中出现的顺序”。更精确地说,确定由小写英文字母组成的两个不同字符串 和 的顺序的算法如下:
这里,“ 的第 个字符”表示为 。如果 在字典顺序上小于 ,我们写 ,如果 更大,我们写 。
- 设 为 和 中较短字符串的长度。检查 和 是否匹配,对于 。
- 如果存在一个 使得 ,设 为最小的这样的 。比较 和 。如果 在字母顺序上小于 ,那么 。否则,。算法在这里结束。
- 如果没有 使得 ,比较 和 的长度。如果 比 短,那么 。如果 更长,那么 。算法在这里结束。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
AtCoder users have gathered to play AtCoder RPS 2. The -th user's name is and their rating is .
AtCoder RPS 2 is played as follows:
- Assign the numbers to the users in lexicographical order of their usernames.
- Let be the sum of the ratings of the users. The user assigned the number is the winner.
Print the winner's username.
What is lexicographical order?
Lexicographical order, simply put, means "the order in which words appear in a dictionary." More precisely, the algorithm to determine the order of two distinct strings and consisting of lowercase English letters is as follows:
Here, "the -th character of " is denoted as . If is lexicographically smaller than , we write , and if is larger, we write .
- Let be the length of the shorter string among and . Check if and match for .
- If there exists an such that , let be the smallest such . Compare and . If is alphabetically smaller than , then . Otherwise, . The algorithm ends here.
- If there is no such that , compare the lengths of and . If is shorter than , then . If is longer, then . The algorithm ends here.
Constraints
- is a string consisting of lowercase English letters with length between and , inclusive.
- are all distinct.
- is an integer.
Input
The input is given from Standard Input in the following format:
Output
Print the answer on a single line.
Sample Input 1
3
takahashi 2
aoki 6
snuke 5
Sample Output 1
snuke
The sum of the ratings of the three users is . Sorting their names in lexicographical order yields aoki
, snuke
, takahashi
, so aoki
is assigned number , snuke
is , and takahashi
is .
Since , print snuke
, who is assigned number .
Sample Input 2
3
takahashi 2813
takahashixx 1086
takahashix 4229
Sample Output 2
takahashix
相关
在下列比赛中: