hdu1003 最大子串和
2016-05-04 23:00
501 查看
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 207874 Accepted Submission(s): 48646
[align=left]Problem Description[/align]
Given a sequence a[1],a[2],a[3]......a
, 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.
[align=left]Input[/align]
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).
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
[align=left]Sample Output[/align]
Case 1:
14 1 4
Case 2:
7 1 6
[align=left]Author[/align]
Ignatius.L
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 , 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 Author Ignatius.L
View Code
相关文章推荐
- VR资源
- 安卓真机模拟 com.android.ddmlib.AdbCommandRejectedException: device offline
- LeetCode 53. Maximum Subarray
- Android Studio教程从入门到精通
- More Effective C++----(7)不要重载"&&"、"||"、","
- 在控制台程序中隐藏控制台窗口
- 输入一个表示整数的字符串,把该字符串转换成整数并输出。例如输入字符串"345",则输出整数345
- js函数封装
- NTP服务一大波安全漏洞已修复,请尽快升级
- 20.Postfix Completion 的使用 - IntelliJ IDEA 使用教程
- windows程序消息处理流程
- 退出应用程序
- 素数求和问题【nyoj22】
- python(二)拾遗
- 【翻译】 Unity3D VR 教程:2.开始进行VR开发
- Tomcat内置连接池管理
- 剑指offer 面试题30:最小的K个数(topK问题) 题解
- docker镜像
- PHP多维数组元素操作类
- 帧动画和补间动画