#K84602. Leaderboard Generation

    ID: 36456 Type: Default 1000ms 256MiB

Leaderboard Generation

Leaderboard Generation

You are given an integer n representing the number of participants followed by n lines each containing two integers: an identifier and a score. Your task is to generate a leaderboard by sorting the participants primarily by their scores in descending order and secondarily by their identifiers in ascending order if scores are equal.

The problem involves a simple sorting mechanism and is a good test of basic programming skills and handling of standard input/output. Use stdin for input and stdout for output.

The sorting criteria can be mathematically represented as:

Sort by \( (-score, identifier) \).

inputFormat

The first line contains an integer n (\(1 \leq n \leq 10^5\)) representing the number of participants. The following n lines each contain two integers separated by a space: the participant's identifier and score. For example:

5
1001 95
1002 85
1003 95
1004 75
1005 85

outputFormat

Output the sorted leaderboard, one participant per line, where each line contains the participant's identifier and score separated by a space. The leaderboard is sorted by score in descending order, and if two participants have the same score, by identifier in ascending order.

1001 95
1003 95
1002 85
1005 85
1004 75
## sample
5
1001 95
1002 85
1003 95
1004 75
1005 85
1001 95

1003 95 1002 85 1005 85 1004 75

</p>