#P9367. [ICPC 2022 Xi'an R] Strange Sum
[ICPC 2022 Xi'an R] Strange Sum
Description
Given a sequence .
You are going to select zero or more elements of so that: if you select , then in any interval of length (formally, in for any ) you can select at most elements.
Calculate the maximal sum of the elements you select.
Input Format
The first line contains an integer ().
The second line contains integers ().
Output Format
Output a single integer denoting the answer.
4
1 4 3 2
7
3
-10 -10 -10
0
Hint
Source: The 2022 ICPC Asia Xi'an Regional Contest Problem J.
Author: JohnVictor.
京公网安备 11011102002149号