You are playing a game called RuinScape and are currently fighting a tough boss named Araxxi (she is a spider). The fight will last for
Since you are a skilled player, you know that the key to winning the fight is to counter as many of Araxxi's special attacks as you can. You know the techniques to counter each of the
Activating a technique is done on the same unit of time as, but an infinitesimal amount of time before Araxxi's special attack (so if Araxxi uses the attack your technique counters on that unit of time, you will successfully counter it). You can switch techniques during the fight, but after cancelling a technique, there is a delay before you can activate the next technique, meaning you must take unavoidable damage from the special attacks that occur during the delay after you cancel the current technique. Specifically, if the delay has a value
Input Specification
The first line of input will contain two integers
The second line of input will contain
The third line of input will contain
Output Specification
The first and only line of output should contain the maximum number of special attacks you can counter.
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [20%]
Subtask 3 [20%]
All the delays are equal to
Subtask 4 [40%]
No additional constraints.
Sample Input
5 2
1 2 2 1 2
0 2
Sample Output
4
Explanation of Output for Sample Input
The optimal strategy is to activate the technique to counter type 1 special attacks just before Araxxi uses her first attack, and immediately after, switch to the technique to counter type 2 special attacks and keep using that technique until the end of the fight. You will get hit by one type 1 attack, but you will have managed to counter 4 attacks.
Comments
Kappa.
kc?
Add me
Added.