当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

BZOJ3638:Cf172 k-Maximum Subsequence Sum

题目描述

给一列数,要求支持操作: 1.修改某个数的值 2.读入l,r,k,询问在[l,r]内选不相交的不超过k个子段,最大的和是多少。

输入解释

The first line contains integer n (1 ≤ n ≤ 105), showing how many numbers the sequence has. The next line contains n integers a1, a2, ..., an (|ai| ≤ 500).

The third line contains integer m (1 ≤ m ≤ 105) — the number of queries. The next m lines contain the queries in the format, given in the statement.

All changing queries fit into limits: 1 ≤ i ≤ n, |val| ≤ 500.

All queries to count the maximum sum of at most k non-intersecting subsegments fit into limits: 1 ≤ l ≤ r ≤ n, 1 ≤ k ≤ 20. It is guaranteed that the number of the queries to count the maximum sum of at most k non-intersecting subsegments doesn't exceed 10000.

输出解释

For each query to count the maximum sum of at most k non-intersecting subsegments print the reply — the maximum sum. Print the answers to the queries in the order, in which the queries follow in the input.

输入样例
9
9 -8 9 -1 -1 -1 9 -8 9
3
1 1 9 1
1 1 9 2
1 4 6 3
输出样例
17
25
0
提示

In the first query of the first example you can select a single pair (1, 9). So the described sum will be 17.


Look at the second query of the first example. How to choose two subsegments? (1, 3) and (7, 9)? Definitely not, the sum we could get from (1, 3) and (7, 9) is 20, against the optimal configuration (1, 7) and (9, 9) with 25.


The answer to the third query is 0, we prefer select nothing if all of the numbers in the given interval are negative.

BZPRO Powered by Remmina.
Github Repository
来自acmore.cc的附加信息
bzoj_id 3638
import_source_sha256 fea180d2c1f4084786df9a032e9de91817bc2eefa6c4a8e621d4761c4badc2e6
bzoj_checker_pending False

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 3638

源链接: LOCAL-BZOJ3638

共提交 0 次

通过率 --%
时间上限 内存上限
50000 MS 256 MB