You are planning a heist on one of the worst museums in the world. You've already planned out the entrance and exit routes (consisting of simply walking in and then walking out), so the only task left is to decide which artifacts to bring home. Specifically, the
Input Specification
The first line contains an integer
The first line of each case contains
The second line of each case contains
Output Specification
Output
Constraints
For this problem, you will NOT be required to pass the sample case in order to receive points. In addition, you do not have to pass all previous subtasks to earn points for a specific subtask.
For all subtasks:
The sum of
Subtask 1 [15%]
The sum of
Subtask 2 [25%]
Subtask 3 [60%]
No additional constraints.
Sample Input
4
5 2
3 1 0 4 5
2 1
-1 -2
4 4
6 1 3 3
9 3
-3 7 -6 1 1 4 2 3 2
Sample Output
10
0
13
18
Explanation
The diagram above illustrates the optimal solution to the first case, with the chosen artifacts marked in green. Note that it is not allowed to choose the artifacts with values
In the second case, it is optimal to take nothing at all. (and maybe find a better museum…)
In the third case, it is optimal to take all
The optimal solution to the fourth case is illustrated below, with the chosen artifacts marked in green.
Comments