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. MonoSingleton——Unity中的单例模式

    Unity中有很多特别的类需要以单例模式呈现,比如全局的UI管理类,各种缓存池,以及新手导航类等等.而Unity中,因为所有继承自Monobehaviour的脚本在实现的时候都是单线程的,所以像网上流 ...

  2. hadoop常见问题总结1

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-problem1.html,转载请注明源地址. 问题1:http://localhost:50030 H ...

  3. Android Logger日志系统

    文件夹 文件夹 前言 执行时库层日志库liblog 源代码分析 CC日志写入接口 Java日志写入接口 logcat工具分析 基础数据结构 初始化过程 日志记录的读取过程 前言 该篇文章是我的读书和实 ...

  4. Jquery chosen动态设置值 select Ajax动态载入数据 设置chosen和获取他们选中的值

      在做一个编辑对话框时,要对里面带有select option的操作.主要是想动态载入option和对option的选中.可是由于项目中使用了jquery里的chosen()方法.怎么也无法实现效果 ...

  5. TZOJ 1072: 编辑距离(动态规划)

    1072: 编辑距离 时间限制(普通/Java):1000MS/10000MS     内存限制:65536KByte 总提交: 917            測试通过:275 描写叙述 如果字符串的 ...

  6. STM32 控制GSM模块收发信息 F407 discovery

    main.c #include "stm32f4_discovery.h" #include <stdio.h> #define LED1_ON GPIO_SetBit ...

  7. Xamarin C# Android for Windows 安装

    Xamarin C# Android for Windows  安装 Xamarin的. Android手动安装 安装Xamarin的  Android在Windows机器上   大多数时候,Xama ...

  8. send返回值

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

  9. jtemplate 为javascript前端html模版引擎

    最近的项目中用到了jtemplate, 它是客户端基于javascript的模板引擎,绑定的数据为json对象.以前我在页面上显示数据列表时最喜欢用Repeater控件了,因为它相对与其它几个服务端控 ...

  10. TP框架ajax U方法不解析怎么办?

    TP框架中ajax U方法不解析 ajax U方法不解析 ajax url不解析 问题: 造成问题原因: Js 存在单独的 js文件中和html分离了.造成不解析! 解决方法: 方法一:将js放到ht ...