#K47377. Player Rankings
Player Rankings
Player Rankings
You are given a sequence of rounds in which players earn points. In each round, you will receive two integers: a player identifier and the points earned in that round. The final ranking of the players is determined by their total points. In particular, let (S_i) denote the total score of player (i), i.e., (S_i = \sum_{j} \text{score}_{i,j}). The players should be ranked in descending order of (S_i). In the event of a tie (i.e. two or more players have the same total points), the player with the smaller identifier is ranked higher.
Your task is to implement a program that reads the rounds from the standard input and prints the final ranking as a list of player identifiers, separated by spaces, to the standard output.
inputFormat
The first line contains a single integer (n) representing the number of rounds. The following (n) lines each contain two integers separated by a space: the player's identifier and the points earned in that round.
outputFormat
Output a single line containing the player identifiers in the final ranking order, separated by spaces. The ranking is based on descending total points, with ties broken by the player identifier in increasing order.## sample
8
1 10
2 15
3 5
1 -5
2 -10
3 10
1 20
2 5
1 3 2
</p>