The Second Rhythm Game of Goinmul
Time limit2sMemory limit1024 MB
For each level with gauge cap X and fever length Y, find the maximum total score when fever time is activated each time the gauge fills.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Two pointers, Prefix sum, Sorting
- Solved
- No attempts yet
Problem
Karuna, a national rhythm game team member and a key figure in the World Cup semifinals, started a new rhythm game to dominate the genre.
The song Karuna plays consists of several notes. Each note must be hit exactly seconds after the song starts, and hitting it gives a score and energy . The final score is the sum of the scores from all notes. may be negative, but Karuna ignores that and always hits every note at the exact time.
The game also has a fever system. The fever gauge starts at 0. Each time a note is hit, the gauge rises by the energy from that note. However, if the fever gauge exceeds , it is capped at .
When the fever gauge reaches , Karuna can activate fever time at any moment. Fever time lasts exactly seconds, and notes processed during fever time score double. Notes processed at the moment fever time starts or ends also score double. The fever gauge does not rise during fever time, and it resets to 0 right after fever time ends.
The game has several difficulty levels. Each level has its own maximum fever gauge and fever time length . For each level, find the maximum score Karuna can obtain.
Input
The first line contains the number of notes .
Each of the next lines contains the time , score , and energy of a note. All are guaranteed to be distinct.
The next line contains the number of difficulty levels .
Each of the next lines contains the maximum fever gauge and fever time length of a level.
Output
Print lines. The -th line contains the maximum score Karuna can obtain at the -th difficulty level.
Constraints
- All numbers in the input are integers.