#K76542. Leaderboard Generation
Leaderboard Generation
Leaderboard Generation
You are given a list of participants along with their scores. Your task is to generate a leaderboard by sorting the participants based on the following criteria:
- Participants with a higher score should appear before those with a lower score.
- If two participants have the same score, they should be sorted in ascending lexicographical order (alphabetical order) by their names.
This sorting criteria can be expressed mathematically as: $$\text{Sort} = (-\text{score}, \text{name})$$
Input is provided through standard input (stdin) and the output should be printed to standard output (stdout). Each participant's name must be printed on a separate line.
inputFormat
The first line of input contains an integer T, the number of participants. Each of the following T lines contains a string (the participant's name) and an integer (the participant's score), separated by a space.
outputFormat
Output the names of the participants in the order determined by the above criteria. Each name should be printed on a separate line.## sample
5
Alice 300
Bob 200
Charlie 300
David 150
Eve 200
Alice
Charlie
Bob
Eve
David
</p>