#C13838. Determine the Election Winner
Determine the Election Winner
Determine the Election Winner
You are given an election result list. The first input line contains an integer n indicating the number of candidates. Each of the following n lines contains a candidate's name and the number of votes they received, separated by a space.
Your task is to determine the candidate with the highest number of votes. In case of a tie, the candidate who appears first in the input among those with the maximum votes is chosen. If no votes are given (i.e. n is 0), print None
.
The solution should read from stdin and write the result to stdout.
inputFormat
The first line contains an integer n (n ≥ 0) which represents the number of candidates. Each of the next n lines contains a candidate's name (a string without spaces) and an integer representing the number of votes, separated by space.
outputFormat
Output a single line containing the name of the winning candidate. If n is 0, output None
.
1
Alice 50
Alice
</p>