#K79457. Find Subject with Maximum Enrollment
Find Subject with Maximum Enrollment
Find Subject with Maximum Enrollment
You are given a list of subjects along with their enrollment numbers. Your task is to determine the subject that has the maximum enrollment. In case of a tie (i.e. two or more subjects with the same enrollment), the subject that appears first in the input should be chosen.
The input begins with an integer \( n \) representing the number of subjects. It is followed by \( n \) lines, each containing a subject name (which may be an empty string) and an integer representing the enrollment, separated by space. Output the name of the subject with the highest enrollment.
Note: If there is a tie, output the subject that appears first among those with the maximum enrollment.
inputFormat
The first line contains an integer \( n \) (\( 1 \leq n \leq 10^5 \)), the number of subjects. \( n \) lines follow, each containing a subject name and an integer enrollment separated by a space.
Example:
4 Mathematics 50 Physics 75 Chemistry 65 Biology 60
outputFormat
Output a single line containing the name of the subject with the maximum enrollment. In case of a tie, output the one which appears first in the input.
## sample1
Mathematics 50
Mathematics