#K80897. Leaderboard Sorting for Competitive Programming
Leaderboard Sorting for Competitive Programming
Leaderboard Sorting for Competitive Programming
You are given the results of a competitive programming contest. Each participant's details are provided in the following format:
- The first line contains an integer N representing the number of participants.
- Each of the following N lines begins with the participant's name, followed by several pairs. Each pair consists of a problem identifier and the corresponding score the participant achieved on that problem.
The task is to calculate the total score for each participant using the formula \(T = \sum_{i=1}^{k} s_i\) (where \(s_i\) is the score from the i-th pair) and then produce a leaderboard sorted in descending order of total score. In the event of a tie, participants should be sorted in lexicographical order by their names.
Your program should read from stdin and output the result to stdout.
inputFormat
The input starts with an integer N on a single line, the number of participants. The next N lines each contain a participant's data. The first token is the participant's name, and the rest of the line consists of pairs of values where the first value is the problem identifier (which can be ignored) and the second value is the score for that problem. All tokens are separated by spaces.
outputFormat
Output the leaderboard where each line contains a participant's name and their total score, separated by a space. The leaderboard should be sorted by total score in descending order. If two participants have the same total score, sort them in lexicographical order by name.
## sample4
Alice 1 50 2 60 3 70
Bob 2 40 3 90
Charlie 1 100 2 95
Dave 3 85 1 55
Charlie 195
Alice 180
Dave 140
Bob 130
</p>