#15577. [ICPC 2022 Xi'an R] Strange Sum
[ICPC 2022 Xi'an R] Strange Sum
[ICPC 2022 Xi'an R] Strange Sum
题目描述
Given a sequence $a_1, a_2, \ldots, a_n$.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 $n$ ($2 \leq n \leq 10^5$).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. 标签: P9367|2022|O2优化|ICPC|西安