#C14999. Top Student Selection
Top Student Selection
Top Student Selection
You are given a list of students with their names and scores. Your task is to determine the top student based on the following criteria:
- The student with the highest score is considered the top student.
- If multiple students share the highest score, the student whose name is lexicographically smallest (i.e. comes first in alphabetical order) is the top student.
Formally, let \(n\) be the number of students and let each student be represented as a pair \((name, score)\). You need to output the name of the student satisfying the conditions above.
inputFormat
The input is given via stdin and has the following format:
n name1 score1 name2 score2 ... namen scoren
Where \(n\) is an integer representing the number of students. Each of the next \(n\) lines contains a student's name and score, separated by a space. Names are strings without spaces and scores are integers.
outputFormat
Print to stdout the name of the top student as determined by the criteria. If no students are provided (i.e. \(n = 0\)), output None
.
1
John 85
John