#C1021. Calculate & Sort Player Scores

    ID: 39390 Type: Default 1000ms 256MiB

Calculate & Sort Player Scores

Calculate & Sort Player Scores

Given a single line string of space-separated player-score entries in the format player:score, compute the total score for each player.

For each entry \(a:b\), player \(a\) earns \(b\) points. Sum all scores for each player and then output the results sorted primarily in descending order of total score, and secondarily in ascending order of player number if scores are equal.

If the input is empty, produce no output.

inputFormat

A single line string from standard input containing a space-separated list of entries in the format player:score.

outputFormat

For each player with a nonzero total score, output a line containing two integers: the player number and the total score, separated by a space. The output should be sorted in descending order of total score; if equal, sort by ascending player number.## sample

1:10 2:20 1:15 3:5 2:10 3:8 3:12
2 30

1 25 3 25

</p>