Ranking | 프로그래밍의 벗 PivotOJ
PivotOJ

Ranking

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2020-21 openBOJ 29882

문제

Charlotte Michelle Simone is organizing the Especially Interesting Olympiad. Now she has the solutions of all the participants and needs to compile the ranking.

There are several tasks in the olympiad. Each participant can submit any number of solutions for each task, and each solution scores some number of points. The score of a participant 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). The total score of a participant is the sum of their scores over all tasks.

Write a program to compile the ranking of the participants according to their total scores.

입력

The first line contains an integer NN, the number of solutions submitted (1N2000001 \le N \le 200\,000).

Each of the following NN 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 from each other by spaces. Each account name and each task name consists of 1 to 20 lower-case letters of the Latin alphabet. Each solution may score 0 to 100 points (always an integer).

You may assume that there are no more than 1000010\,000 participants and no more than 1010 tasks.

출력

Output one line per participant, listing their account name and total score, separated by a space. The lines should be ordered in the non-increasing order of the scores. The lines with equal scores may be listed in any order.

예제

예제 1

입력
6
juku tul 3
mari har 5
mari har 4
juku har 4
mari tul 1
mari tul 5
출력
mari 10
juku 7
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.