
You all probably know what Guitar Hero is.
Basically, you just strum a bunch of notes (
But one interesting aspect is Star Power: the ability to double your points for a certain time.
After you play a certain sequence of notes correctly, your Star Power meter will fill up by one notch.
You can activate Star Power at any time.
When activated, the meter starts to drain and each "notch" will give you some time
For our purposes the meter is infinite, and you don't need a minimum number of notches to activate it.
Also, once you activate Star Power, you cannot deactivate it.
If you happen to accumulate more Star Power while it is active, it will just add onto your meter (and it will get used up).
Here's the interesting part: sometimes it's better to save Star Power for later (i.e. save it for an insane section).
So, you've mastered the game to the point where you can play all the notes perfectly.
Now you'd like to maximize your score (with the help of a program), so that you can set a high score!
Input Specification
There are no chords; all notes will have unique times.
As an example, if there are
(Obviously, the notes come in order of time)
None of these sequences will overlap.
All numbers in the input are positive integers.
Output Specification
Your maximum possible score.
Sample Input 1
10 4
2 1
100 2
600 3
600 4
1 6
2 7
2 8
2 9
10 10
1 5
1
3 4
Sample Output 1
1337
(Note that the times may not be in order.)
Save your Star Power, then activate it right when you play the note at time
Star Power ends just when you play the note at time
This way you get
Sample Input 2
5 1
1 100
1 200
1 300
1 600
1 700
3
1 1
2 2
4 4
Sample Output 2
7
Activate Star Power at time
Later, activate it at time
Comments