#K81937. Top Student Selection
Top Student Selection
Top Student Selection
You are given a list of student records. Each record consists of a student's name and their exam score. The task is to determine the top student. The top student is defined as the student with the highest score. In case of a tie, the student whose name comes first in alphabetical order is chosen. If the list of students is empty, output None
.
Formally, given a list of tuples \[ (name_i, score_i) \quad for \quad i=1,2,\dots,n \] find the student \(s\) such that \[ score_s = \max_{i} score_i \] and if there exists \(i, j\) with \(score_i = score_j = score_s\), then choose the one with the smallest name in lexicographical order.
inputFormat
The input is read from stdin
and has the following format:
- The first line contains an integer n, which is the number of students.
- The following n lines each contain a student's name and an integer score separated by a space.
If n is 0
, there are no students in the list.
outputFormat
Output the name of the top student to stdout
. If there are no students, output None
.
1
John 88
John
</p>