Korean, English, math
InterviewTime limit1sMemory limit256 MB
Sort N students by Korean score descending, English ascending, math descending, then name in ASCII order and print the names.
- Level
Easy3 of 10
- Topics
- Sorting
- Solved
- No attempts yet
Problem
You are given the name and the Korean, English, and math scores of N students. Write a program that sorts the students by the following rules, applied in order.
- Korean score in decreasing order
- If the Korean scores are equal, English score in increasing order
- If the Korean and English scores are equal, math score in decreasing order
- If all three scores are equal, name in increasing dictionary order
Names are compared by ASCII value. An uppercase letter has a smaller value than a lowercase letter, so it comes first.
Input
The first line contains the number of students N ().
Each of the next N lines contains a student's name and Korean, English, and math scores, separated by single spaces. Every score is a natural number between 1 and 100. A name consists only of uppercase and lowercase letters and is at most 10 characters long. Two or more students may share the same name.
Output
Print the name of each student on its own line, N lines in total, in the sorted order.