Max Sum
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 66583Accepted Submission(s): 15239
Problem Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.
Input
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<=100000), then N integers followed(all the integers are between -1000 and
1000).
Output
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 three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end
position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.
Sample Input
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
Sample Output
Case 1:
14 1 4
Case 2:
7 1 6
DP 动态规划的题。这道题很久以前就看过 ,那个时候还不知道什么动态规划, 用暴力求解 , 总是TLE。 今天从算法书上看了点动态规划的知识。终于顺利 把此题AC了。但过程还是花了很久。 因为我一直把 最大子序列的和 maxsum 初值定为 0 , 没考虑全为负数! 关于DP,今晚刚开始看,所以还需要点时间。 这道题 思路写在注释中。
分享到:
相关推荐
关于hdu的动态规划的题目,包括一些水题,还有一些经典的动态规划题目。
HDU 动态规划(46道题目
动态规划DP题解 POJ HDU部分动态规划DP题解
hdu动态规划算法集锦
HDU的一题........HDU DP动态规
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
杭电acm1297 #include<stdio.h> #include<string.h> #define m 1002 int f[m][70]={{1,1},{1,1},{1,2},{1,4}} void add(int p[],int q[],int sum[]) ...=10000){sum[i]-=10000 sum[i+1]++ } }
HDU动态规划,此PPT系杭州电子科技大学ACM总教练刘春英老师所有, 特在此分享贡献给广大编程爱好者, 特别是ACMer!
杭电ACM课件2014版之 (HDUACM201403版_05)动态规划
动态规划DP题解 POJ HDU 动态规划解题报告
算法设计与分析实验六:使用动态规划算法解决存钱问题(java实现、hdu1114)(csdn)————程序
动态规划入门,hdu上的动态规划入门题的结题报告。 hdu 1171,hdu 1059,hdu 2159,hdu 2191,hdu 3496
(lecture_04)动态规划(1)_ (lecture_05)计算几何基础_ (lecture_06)母函数 (lecture_7)特殊的数 (lecture_8)组合博弈入门 (lecture_09贪心算法 (lecture_11)搜索入门 (lecture_12)二分匹配及其应用 ...
这是一个相当齐全的算法课件 里面包含了很多的内容和实例 使我们上课时老师的课件 希望对大家有帮助
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
杭电ACMhdu1163
HDU1059的代码
hdu1001解题报告