#K40507. Student Ranking
Student Ranking
Student Ranking
You are given data for n students. For each student, you are provided with the student's name and scores in three subjects: Math, Science, and English.
Your task is to rank the students based on their average score calculated as \(\frac{\text{Math} + \text{Science} + \text{English}}{3}\). In case of ties in the average score, the tie is broken by the Math score (in descending order). If there is still a tie, then the students are ranked by their names in lexicographical (alphabetical) order.
Note: All scores are integers. The final output should be the names of the students sorted according to the above criteria, printed on a single line separated by spaces.
inputFormat
The first line contains an integer n
(\(1 \le n \le 10^5\)), representing the number of students.
Each of the following n
lines contains the student's information in the following format:
name Math Science English
where name
is a string without spaces and Math
, Science
, English
are integers.
outputFormat
Print a single line containing the names of the students sorted based on the ranking criteria. The names should be separated by a single space.
## sample4
John 80 90 85
Doe 90 70 80
Jane 85 80 80
Smith 90 85 90
Smith John Jane Doe