Recommend the Next Morgorithm President
InterviewTime limit1sMemory limit1024 MB
Given N distinct names with scores, print the name with the highest score, breaking ties by lexicographically smallest name.
- Level
Easy2 of 10
- Topics
- Implementation, Sorting, String
- Solved
- No attempts yet
Problem
Gukryeol needs to find the next president of Morgorithm quickly. Otherwise, he will have to serve as president even in graduate school.
So Gukryeol tried to hold the 2020 Yonsei University Programming Contest to choose the next president, but the contest was postponed because of COVID-19 and ended up being held in November.
Gukryeol wants to force the person with the highest score among the contest participants to become the next president. If two or more people have the highest score, the person whose name comes first in lexicographic order will be chosen as the next president.
Determine who will be chosen as the next president.
Input
The input is given as follows.
N
A1 B1
. . . . . .
AN BN
Output
On the first line, print the name of the person who will be chosen as the next president.
Constraints
- 1 ≤ N ≤ 100,000. N is a positive integer representing the number of people.
- Ai is a string of lowercase English letters with length between 1 and 10, and it is the name of a participant. (1 ≤ i ≤ N)
- Ai ≠ Aj (1 ≤ i < j ≤ N)
- 1 ≤ Bi ≤ 1,000,000,000 (1 ≤ i ≤ N). Bi is a positive integer representing a score.