Section: 3, Score: 33, Time limit per test: 30 seconds, Memory limit per test: 512MB, Input: stdin, Output: stdout
Agoda is an online travel booking platform that offers hotel and accommodation reservation services worldwide. If someone books accommodation, we call them a booker. Sometimes the booker wants to cancel a booking. For simplicity of the problem, per cancellation attempt, a booker can only cancel their last booking. If there is no last booking, the operation has no impact. If they want to cancel two previous bookings, they need to send two cancel commands to the system. Sometimes we want to know who is booking the maximum number of accommodations. In this problem, your job is to help us find the bookers who have more than a certain number of bookings.
The first line of the input contains an integer
B booker_id
: meaning that the booker_id has booked accommodation.C booker_id
: meaning that the booker_id has canceled one previous booking.P K
: print how many bookers have at least K bookings and sum of all bookings from them.
For every input of type 3(print command) print two integers separated by a single space. The first integer should indicate how many bookers have at least
11
B 1
B 3
B 6
P 1
B 6
P 1
B 6
P 2
C 6
C 6
P 2
3 3
3 4
1 3
0 0
- For the first print(P) command, we have 3 bookers (1, 3, 6). Each of them booked only one accommodation. So, the output is 3 3.
- For the second print(P) command, the booker with id 6 has booked 2 accommodations and others have one booking each. Therefore, they all have at least one booking and the total sum of their bookings is 4. So, the output is 3 4.
- For the third print(P) command, we can see that only booker id 6 has at least two bookings. And he has 3 bookings. Thus, the output is 1 3.
- For the last print(P) command, we see no booker has at least 2 bookings. Therefore, the output is 0 0.
17
B 4
P 1
C 5
C 5
B 5
B 5
C 3
C 4
B 5
P 3
B 4
P 1
B 6
B 4
C 4
B 4
P 3
1 1
1 3
2 4
1 3