#C6336. Participant Ranking in a Coding Competition
Participant Ranking in a Coding Competition
Participant Ranking in a Coding Competition
In this problem, you are given the number of participants and the number of problems in a coding competition. Each participant's score for every problem is provided. If a participant did not attempt a problem, the score for that problem is given as -1, and it should not be included in the total score. The total score (S) for a participant is calculated as: [ S = \sum_{i=1}^{N} s_i \quad \text{(ignoring scores where } s_i = -1\text{)} ] Participants are then ranked in descending order based on their total scores. In the event of a tie, participants with equal scores receive the same rank and are ordered lexicographically by name.
Your task is to implement a program that reads the input from standard input and prints the ranking to standard output. Each output line should contain the participant's name, their total score, and their rank, separated by spaces.
inputFormat
The first line of the input contains two integers (P) and (N), where (P) is the number of participants and (N) is the number of problems. Each of the next (P) lines contains a participant's name followed by (N) integers representing the scores for each problem. A score of -1 indicates that the problem was not attempted.
outputFormat
For each participant, output a single line containing the participant's name, the total score (sum of all valid scores), and the rank, separated by a space. The participants should be listed in order of their ranking, which is determined first by the total score in descending order and then by name in lexicographical order if the scores are equal. Participants with the same total score should receive the same rank.## sample
3 3
Alice 50 150 -1
Bob -1 200 250
Charlie 30 100 300
Bob 450 1
Charlie 430 2
Alice 200 3
</p>