Misaka is fighting against an enemy army consisting of
After using her Railgun ability at most
Constraints
Subtask 1 [2/15]
The robots are sorted in non-decreasing order in terms of power.
Subtask 2 [9/15]
Subtask 3 [4/15]
No additional constraints.
Input Specification
The first line of input contains
The second line of input containts
Output Specification
Output a positive integer, the sum of the destroyed robots' powers.
Sample Input 1
5 2 1
1 2 3 4 5
Sample Output 1
9
Explanation for Sample Output 1
Misaka can destroy the
Sample Input 2
10 2 3
10 1 3 2 9 9 8 9 1 1
Sample Output 2
37
Explanation for Sample Output 2
To attack optimally, Misaka first destroys the
The robots' powers now become:
Then, she destroys the
The robots' powers now become:
Finally, she destroys the
The robots' powers now become:
In total, she weakened the army by
Sample Input 3
11 4 2
9 4 1 3 2 1 3 2 9 1 1
Sample Output 3
30
Explanation for Sample Output 3
To attack optimally, Misaka first destroys the
The robots' powers now become:
Then, she destroys the
The robots' powers now become:
In total, she weakened the army by
Sample Input 4
5 4 5
1 1 1 1 1
Sample Output 4
5
Explanation for Sample Output 4
All robots are destroyed no matter how she attacks.
Comments