Logo
(追記) (追記ここまで)

30220번 - Rightsizing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB21171482.353%

문제

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.

제한

예제 입력 1

5 6
eduardo 6000000
mark 7000000
andrew 5000000
dustin 1000000
chris 500000
2
1 andrew 2000000
1 dustin 5000000
2
2
2

예제 출력 1

mark 7000000
andrew 7000000
dustin 6000000
eduardo 6000000

예제 입력 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

예제 출력 2

d 11
b 11
h 11
j 10
a 9
e 9

힌트

출처

University > University of Central Florida > 2023 Local Programming Contest (Qualifying Round) 7번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /