hdu1003 最大子串和
2024-10-11 04:36:43
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 207874 Accepted Submission(s): 48646
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
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
Sample Output
Case 1:
14 1 4
14 1 4
Case 2:
7 1 6
Author
Ignatius.L
Max Sum Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): Problem Description
Given a sequence a[],a[],a[]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (,-,,,-), the max sum in this sequence is + (-) + + = . Input
The first line of the input contains an integer T(<=T<=) which means the number of test cases. Then T lines follow, each line starts with a number N(<=N<=), then N integers followed(all the integers are between - and ). 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 - -
- - - Sample Output
Case : Case : Author
Ignatius.L
最新文章
- [C#] 走进异步编程的世界 - 剖析异步方法(上)
- c#线程间操作无效: 从不是创建控件“textBox1”的线程访问它
- ionic
- SDK接入(U8SDK)——SDK抽象层的设计
- JS代码格式化和语法着色
- Xcode真机调试中";There was an internal API error";错误解决方法
- NOI剑客决斗
- NGUI基础之button(按钮)
- Asp.Net 之 WebService部署到服务器后出现"; The test form is only available for requests from the local machine ";
- C#边边角角(一)
- 解决mydql执行sql文件时报Error: Unknown storage engine &#39;InnoDB&#39;的错误。
- OpenStack架构详解
- Python selenium webdriver设置js操作页面滚动条
- django 存在则忽略, 不存在则创 TagSheet.objects.get_or_create(tag=&#39;test&#39;)
- BZOJ 4591 【SHOI2015】 超能粒子炮&#183;改
- kafka安装和部署
- YOLO V1论文理解
- Eclipse “cannot be resolved to a type”
- 多进程监控自动关机工具升级远程关闭多台server——C# works with PowerShell
- 【顽固BUG】Visual Studio 2015 + TestDriven.NET-3.8.2860_Personal_Beta 调用的目标发生了异常。
热门文章
- 融合libevent和protobuf
- MYSQL三个默认库的介绍
- dedecms织梦 v5.6 两处跨站漏洞
- 微软URLRewriter.dll的url重写的简单使用(实现伪静态)
- jquery easyui里datagrid用法记录
- Android触控屏幕Gesture(GestureDetector和SimpleOnGestureListener的使用教程) 分类:Androidandroid实例
- Linux0.11内核剖析--内核代码(kernel)--sched.c
- Chrome 制作绿色便携版
- Transform数据权限浅析1之mdl语句批量加载权限
- token 案例,只是测试,功能并不完善(只是看看token 到底是何方神圣)