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

建议使用的浏览器:

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

3421:Max Sum II

题目描述
Given a sequence a[1],a[2],a[3]......a[n], you can cut the sequence into one or more consecutive sub-sequences as you want, for example, you can cut them into (a[1]...a[j]), (a[k]...a[l]), (a[m]...a[n]),1≤j<k≤l<m≤n. Your job is to make the maximum sum using the least number of consecutive sub-sequences. For example, given (6,-1,0, -2, 3), the max sum in this sequence is 9, the number of sub-sequences is 2 not 3, they are(6), (3).
输入解释
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=1000000), then N integers followed(all the integers are between -1000 and 1000).
输出解释
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains two integers, the number of consecutive sub-sequences and the max sum. Output a blank line between two cases.
输入样例
2
2 6 -5
5 6 -1 0 -2 3
输出样例
Case 1:
1 6

Case 2:
2 9
来自杭电HDUOJ的附加信息
Author Westwind Bolws@HDU
Recommend lcy

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

源链接: HDU-3421

最后修改于 2020-10-25T23:03:22+00:00 由爬虫自动更新

共提交 0

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