luogu#P9367. [ICPC2022 Xi'an R] Strange Sum
[ICPC2022 Xi'an R] Strange Sum
题目描述
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.
输入格式
The first line contains an integer ().
The second line contains integers ().
输出格式
Output a single integer denoting the answer.
4
1 4 3 2
7
3
-10 -10 -10
0
提示
Source: The 2022 ICPC Asia Xi'an Regional Contest Problem J.
Author: JohnVictor.