Ranking
InterviewTime limit1sMemory limit1024 MB
Given N solutions, each with a participant, a task, and points, output each participant's total, where each task counts only the best score they submitted.
Problem
Charlotte Michelle Simone is organizing the Especially Interesting Olympiad. She has received the solutions of all the participants and needs to compile the ranking.
The olympiad has several tasks. Each participant can submit any number of solutions for each task, and each solution scores some number of points. A participant's score for a task is the maximum of the scores of their solutions for that task (or zero, if they did not submit any solutions for that task). A participant's total score is the sum of their scores over all tasks.
Write a program that compiles the ranking of the participants according to their total scores.
Input
The first line contains an integer , the number of solutions submitted ().
Each of the following lines describes one solution, giving the account name of the participant, the name of the task, and the number of points the solution scored, separated by spaces. Each account name and each task name consists of 1 to 20 lower-case letters of the Latin alphabet. Each solution scores an integer from 0 to 100.
You may assume that there are no more than 10,000 participants and no more than 10 tasks.
Output
Output one line per participant, listing their account name and total score, separated by a space. The lines are ordered by non-increasing total score. Lines with equal scores may be listed in any order.