#C12272. Sort Records by Score
Sort Records by Score
Sort Records by Score
In this problem, you are given a list of records. Each record consists of a name and an integer score. Your task is to sort these records in descending order by the score. In the case where two records have the same score, sort them in alphabetical order by name.
The sorting criteria can be summarized as follows:
[ \text{Record A comes before Record B if } (s_A > s_B) \text{ or } (s_A = s_B \text{ and } name_A < name_B), ]
where (s_A) and (s_B) are the scores of records A and B respectively.
You are required to read input from standard input and write the result to standard output. Output the sorted names on a single line, separated by spaces.
inputFormat
The first line contains a single integer (n) representing the number of records. (n) can be zero. Each of the following (n) lines contains a record with a name and an integer score separated by a space.
outputFormat
Output a single line containing the names sorted according to the described criteria, with a single space separating each name. If there are no records, output an empty line.## sample
4
Alice 92
Bob 95
Charlie 95
Dave 88
Bob Charlie Alice Dave
</p>