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
 
Sample Output
Case 1:
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
 

hdu1003 最大子串和的更多相关文章

  1. hdu1003 Max Sum(最大子串)

    https://vjudge.net/problem/HDU-1003 注意考虑如果全为负的情况,特判. 还有输出格式,最后一个输出不用再空行. #include<iostream> #i ...

  2. [ACM_动态规划] hdu1003 Max Sum [最大连续子串和]

    Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...

  3. LeetCode[5] 最长的回文子串

    题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum ...

  4. 最长回文子串-LeetCode 5 Longest Palindromic Substring

    题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum ...

  5. C语言计算字符串子串出现的次数

    #include<stdio.h>#include<string.h>int substring(char *str,char *str1);//函数原型int main(vo ...

  6. [LeetCode] Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串

    Given a string S, find the length of the longest substring T that contains at most two distinct char ...

  7. [LeetCode] Minimum Window Substring 最小窗口子串

    Given a string S and a string T, find the minimum window in S which will contain all the characters ...

  8. [LeetCode] Substring with Concatenation of All Words 串联所有单词的子串

    You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...

  9. [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串

    Given a string, find the length of the longest substring without repeating characters. For example, ...

随机推荐

  1. 当Windows Server 2012的主DC出了问题, 如何迁移其上的FSMO角色?

    步骤如下: 1. 遵循https://support.microsoft.com/kb/255504中的transfer FSMO的步骤. 2. 这样做之后还没完. 因为Windows Server ...

  2. MS SQL 中判断 数据库, 存储过程,表,临时表,视图,函数,用户,用户创建对象 等是否存在 SQL脚本

    摘自: http://www.111cn.net/database/mssqlserver/39107.htm sql判断存储过程是否存在 判断数据库教程是否存在 Sql代码 if exists (s ...

  3. RS布局问题之块的不完美之完美

    早上一来,便传来喜讯...说我们做的报表太美.客户不敢看----于是便开启征程,亲自尝试了一把,如下面的操作,首次运行报表,在不考虑UI美观度的情况下,报表还是 在预测范围内显示的 那么接下来我们选择 ...

  4. [AngularJS] Angular 1.3 new $q constructor

    <!DOCTYPE html> <html ng-app="app"> <head lang="en"> <meta ...

  5. Netbeans配合xdebug调试

    http://xdebug.org/download.php 下载对应的xdebug的dll不知道php文件中的ext文件夹中 并且加入以下配置在php.info 然后重启apche zend_ext ...

  6. 如何申请iOS开发者证书/发布app到手机

    申请iOS开发者证书 http://blog.csdn.net/htttw/article/details/7939405 如何向App Store提交应用 http://www.cocoachina ...

  7. send返回值

    http://blog.csdn.net/anghlq/article/details/5990513 在Unix系统下,如果send . recv . write在等待协议传送数据时 , socke ...

  8. 偏最小二乘回归(PLSR)- 2 标准算法(NIPALS)

    1 NIPALS 算法 Step1:对原始数据X和Y进行中心化,得到X0和Y0.从Y0中选择一列作为u1,一般选择方差最大的那一列. 注:这是为了后面计算方便,如计算协方差时,对于标准化后的数据,其样 ...

  9. Oracle基础学习2--Oracle登录与三种验证机制

    首先,Oracle安装完毕有三个默认用户 Ø  Sys:数据库对象的拥有者.权限最高.password在安装的时候(口令管理)能够改变 Ø  System:数据库管理员,password为manage ...

  10. 大比速:remoting、WCF(http)、WCF(tcp)、WCF(RESTful)、asp.net core(RESTful) .net core 控制台程序使用依赖注入(Autofac)

    大比速:remoting.WCF(http).WCF(tcp).WCF(RESTful).asp.net core(RESTful) 近来在考虑一个服务选型,dotnet提供了众多的远程服务形式.在只 ...