Chisam's Playlist
Time limit1sMemory limit1024 MB
Simulate playback where each song gains its playlist position per second, remove songs that reach threshold S, and answer max and lookup queries.
- Level
Medium6 of 10
- Topics
- Simulation, Hash map, Heap, Linked list
- Solved
- No attempts yet
Problem

Chisam loves listening to music, so he manages the songs he cares about in one playlist. In the playlist he built himself, every song has a value called "Chisam index". It is defined as follows.
- Every song has a Chisam index, which starts at 0.
- Each second a song is played, its Chisam index increases by its position number in the playlist. For example, a song in position 10 gains 10 for each second it plays. Position 1 is the top of the playlist, and each position below it is 1 larger.
- When playback of a song finishes (the song ends or its play time runs out), the song is removed from the playlist automatically if its accumulated Chisam index is at least S.
The playlist also supports six commands.
Input
The first line contains three integers: the current number of songs N (1 ≤ N ≤ 1,000), the number of commands M (1 ≤ M ≤ 10,000), and the removal threshold S (1 ≤ S ≤ 100,000,000).
From the second line through line N+1, the current playlist is given from top to bottom, each line holding a song title Ai and a positive integer length Ti (1 ≤ Ti ≤ 1,000).
Titles are not repeated, consist only of lowercase English letters, and are at most 50 characters long. From line N+2 onward, M commands are given. The commands are the six described above.
Output
For each command that requires output, print one line.