#K75787. Participant Ranking
Participant Ranking
Participant Ranking
You are given a list of participants along with their full names and integer scores. Your task is to sort the participants according to the following criteria:
- Participants with higher scores come first. In other words, sort in descending order by score.
- If two or more participants have the same score, they should be sorted in lexicographical order (ascending) by their full name.
Note: A participant's name may contain spaces. The score is always the last element in the input line. Use the \(\LaTeX\)
format if including any mathematical expressions.
inputFormat
The first line contains a single integer n
, which denotes the number of participants. Each of the following n
lines contains a participant's full name and an integer score, separated by spaces. Since names may contain spaces, the integer score is guaranteed to be the last token on each line.
outputFormat
Output the full names of the participants sorted based on the above criteria, with each name printed on a separate line.
## sample4
Alice 95
Bob 99
Charlie 95
David 96
Bob
David
Alice
Charlie
</p>