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. 一些LR的经验,讲的还不错

    https://blog.csdn.net/Dinosoft/article/details/50492309 记录一下.

  2. javaScript几个操作数组增减元素的函数

    1. shift:删除原数组第一项,并返回删除元素的值:如果数组为空则返回undefined 2. unshift:将参数添加到原数组开头,并返回数组的长度 var a = [1,2,3,4,5]; ...

  3. java设计模式1--工厂方法模式(Factory Method)

    本文地址:http://www.cnblogs.com/archimedes/p/java-factory-method-pattern.html,转载请注明源地址. 工厂方法模式(别名:虚拟构造) ...

  4. 【中英】mac电脑清理软件 ToolWiz Mac Boost

    简单介绍: ToolWiz Mac Boost是一款适用于Mac电脑清理加速最好的终极应用, 使您的Mac电脑干净有条理, 执行飞速且稳定.始终保持最佳状态! ToolWiz Mac Boost 运用 ...

  5. 【Python】理想论坛每小时发帖量统计图表

    写以下代码的目的是分析一天中各时段理想论坛中用户发帖回帖的活跃程度,获得结尾那张图表是核心. 以下代码两种爬虫协助,论坛爬虫先爬主贴,爬到主贴后启动帖子爬虫爬子贴,然后把每个子贴的发表时间等存入数据库 ...

  6. 关于substring的char[]共享

    我们知道,对于一个较大的String对象假设从中获取一个子串.jdk默认子串的char[]是共享原串的char[].即子串的char[]是原串的char[]中的一部分, 这样对于一个原串多个子串的情况 ...

  7. Javascript的解析器

    Carakan C/C++ http://my.opera.com/core/blog/2009/02... SquirrelFish C++ http://trac.webkit.org/wiki/ ...

  8. Java 并发:内置锁 Synchronized

    摘要: 在多线程编程中,线程安全问题是一个最为关键的问题,其核心概念就在于正确性,即当多个线程訪问某一共享.可变数据时,始终都不会导致数据破坏以及其它不该出现的结果. 而全部的并发模式在解决问题时,採 ...

  9. TP5安装失败怎么办?

    安装TP5遇到这样的错误 TP5安装失败怎么办? [Mon Mar 13 06:24:58.011228 2017] [:error] [pid 10243] [client 192.168.28.1 ...

  10. JavaScript中字符串的match与replace方法

    1.match方法 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配. match()方法的返回值为:存放匹配结果的数组. 2.replace方法 replace() 方 ...