Helping Out

면접 대비

시간 제한1초메모리 제한2048 MB

요약
최대 10^5개의 이름과 점수 쌍이 주어질 때, 각 이름의 점수를 모두 더해 이름을 사전순으로 정렬해 총점과 함께 출력한다.
난이도

쉬움10점 중 3점

유형
해시맵, 정렬, 문자열, 구현
정답자
아직 제출이 없습니다

문제

For the last couple of years gaming competitions have been very popular at the TU Delft. During every competition, any player can obtain up to 100100 points. However, the administration of these competitions has been absolutely terrible, because the result of every competition was written down on a piece of paper and all these were scattered across the TU Delft. A group of students has managed to find (almost) all of these lists of scores, but they would like to compute the total score of each participant. Given a list of (possibly duplicate) names and their scores, help the students out by creating a list of the total score of each participant, sorted in alphabetic order.

입력

On the first line an integer 1≤n≤1051 \leq n \leq 10^5. On the next nn lines, the name (a string containing no spaces) of person MM followed by an integer 1≤k≤1001 \leq k \leq 100, the score of MM in any arbitrary competition.

출력

The output consists of mm lines, where mm is the number of unique names in the input. Give in alphabetic order the names of all participants and their total score, separated by a space.

예제2

  1. 예제 1

    입력
    8
    Grayson 70
    Dante 20
    Anton 60
    Grayson 73
    Grayson 97
    Dante 92
    Tanisha 56
    Grayson 96
    
    예상 출력
    Anton 60
    Dante 112
    Grayson 336
    Tanisha 56
    
  2. 예제 2

    입력
    8
    Alexus 36
    Jaxon 80
    Hali 12
    Shayna 31
    Xavier 46
    Xavier 17
    Jaxon 15
    Alexus 85
    
    예상 출력
    Alexus 121
    Hali 12
    Jaxon 95
    Shayna 31
    Xavier 63