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

建议使用的浏览器:

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

1024:Max Sum Plus Plus

题目描述
Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.

Given a consecutive number sequence S1, S2, S3, S4 ... Sx, ... Sn (1 ≤ x ≤ n ≤ 1,000,000, -32768 ≤ Sx ≤ 32767). We define a function sum(i, j) = Si + ... + Sj (1 ≤ i ≤ j ≤ n).

Now given an integer m (m > 0), your task is to find m pairs of i and j which make sum(i1, j1) + sum(i2, j2) + sum(i3, j3) + ... + sum(im, jm) maximal (ix ≤ iy ≤ jx or ix ≤ jy ≤ jx is not allowed).

But I`m lazy, I don't want to write a special-judge module, so you don't have to output m pairs of i and j, just output the maximal summation of sum(ix, jx)(1 ≤ x ≤ m) instead. ^_^
输入解释
Each test case will begin with two integers m and n, followed by n integers S1, S2, S3 ... Sn.
Process to the end of file.
输出解释
Output the maximal summation described above in one line.
输入样例
1 3 1 2 3
2 6 -1 4 -2 3 -2 3
输出样例
6
8

提示
Huge input, scanf and dynamic programming is recommended.
来自杭电HDUOJ的附加信息
Author JGShining(极光炫影)
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1024

最后修改于 2020-10-25T22:41:29+00:00 由爬虫自动更新

共提交 624

通过率 52.24%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)