아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Rightsizing

시간 제한5초메모리 제한1024 MB

요약
급여 인상과 해고를 처리하며, 해고 때마다 현재 최고 연봉 직원을 알파벳 순 이름으로 동점을 가려서 제거한다.
난이도

보통10점 중 5점

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

문제

Many tech companies have realized that they have “over-hired.” Now, looking at their books, they realize they might have to let go of some employees. In order to prioritize their bottom line, a company will always fire the employee who is making the greatest annual salary at the time. If multiple employees are making the same maximal annual salary, then the person whose name comes first alphabetically will be fired.

Of course, to improve morale, employees can still get raises, which makes figuring out who to fire a bit more tricky.

Given a set of employees and their initial annual salaries, followed by a sequence of actions (either the firing of an employee or giving a raise to a current employee), determine for each firing event, which employee got fired.

입력

The first input line contains two integers: n (1 ≤ n ≤ 105) representing the number of employees in the company, and a (1 ≤ a ≤ 2 × 105) representing the number of actions taken.

The next n input lines will each contain a string, e, representing an employee's name, followed by an integer, s (1 ≤ s ≤ 109), representing employee e's annual salary in dollars. These n lines represent the initial status of the company's employees and their salaries. Each name will be a unique string and will contain 1-20 lowercase letters (starting in column 1).

The next a input lines will each contain information about an action.

If the first integer on one of these input lines is 1, that means that an employee is getting a raise. This will be followed by a string e, representing the employee getting the raise and an integer, r (1 ≤ r ≤ 109), representing the raise amount for employee e. It is guaranteed that each employee getting a raise was listed in the original input and has not been fired yet.

If the first integer on one of these lines is 2, that means the company is firing the employee making the maximum salary. If there is more than one such person, then the person getting fired is the one whose name comes first alphabetically. Since there are n employees, assume that the maximum number of times action 2 will appear in the input is n.

출력

For each firing event (action 2 in the input), print a single line with the name of the employee who got fired and how much they were making annually at the time they were fired, separated by a space.

예제2

  1. 예제 1

    입력
    5 6
    eduardo 6000000
    mark 7000000
    andrew 5000000
    dustin 1000000
    chris 500000
    2
    1 andrew 2000000
    1 dustin 5000000
    2
    2
    2
    
    예상 출력
    mark 7000000
    andrew 7000000
    dustin 6000000
    eduardo 6000000
    
  2. 예제 2

    입력
    10 15
    a 6
    b 5
    c 4
    d 2
    e 1
    f 3
    g 8
    h 10
    i 7
    j 10
    1 c 4
    1 d 9
    2
    1 e 3
    1 h 1
    1 b 6
    2
    2
    1 f 6
    1 a 3
    2
    1 i 2
    2
    1 e 5
    2
    
    예상 출력
    d 11
    b 11
    h 11
    j 10
    a 9
    e 9