博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1003Max Sum(dp)
阅读量:4048 次
发布时间:2019-05-25

本文共 1485 字,大约阅读时间需要 4 分钟。

Max Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 209514    Accepted Submission(s): 49113


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
25 6 -1 5 4 -77 0 6 -1 1 -6 7 -5
 

Sample Output
Case 1:14 1 4Case 2:7 1 6
 

Author
Ignatius.L
注意格式  最后一行没有空格
#include
#include
#include
using namespace std;int main(){ long long n,m,i,k,begin,bbegin,end,eend,max,sum,t; cin>>k; n=1; while(k--) { cin>>m; for(i=1;i<=m;i++) { cin>>t; if(i==1) { sum=max=t; bbegin=begin=eend=end=1; } else { if(sum+t
max) { max=sum; bbegin=begin; eend=i; } } cout<<"Case "<
<<":"<

转载地址:http://kxfci.baihongyu.com/

你可能感兴趣的文章
Love Your Life》—— 热爱生活
查看>>
一个高速交警的忠告
查看>>
新车装饰的中国特色
查看>>
没看过这么NB的自驾游,笑的我眼泪都出来了
查看>>
李涯的哭
查看>>
和机器学习和计算机视觉相关的数学
查看>>
论文MICO for MRI bias field estimation and tissue segmentation品讲
查看>>
后现代
查看>>
VMware6关机后出现is not a valid virtual machine configuration file的解决办法
查看>>
通过ASP实现flash对数据库的访问
查看>>
“==”和equals方法究竟有什么区别?
查看>>
哈佛图书馆墙上的20条训言
查看>>
交流引发深入思考
查看>>
保持我们母语的纯洁
查看>>
免费的互联网时代如何盈利?
查看>>
可怕的宣传力量
查看>>
症状:可以上网,可以上QQ,不能登陆360安全卫士,360浏览器无法同步,有道词典等无法登陆,无法查询。
查看>>
重读《触龙说赵太后》
查看>>
2010的第一次思想触动
查看>>
文学大师做菜艺术20个"须知"
查看>>