超时还有可能是数组开小了……

 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
int num[];
int dp[];
int from[];
int main(){
int T,case_=;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
scanf("%d",&num[]);
int nowmax=num[],nowa=,nowb=;
int ans=num[],a=,b=;
for(int i=;i<=n;i++){
scanf("%d",&num[i]);
if(num[i]+nowmax<num[i]){
nowmax=num[i];
nowa=i;
}
else nowmax+=num[i];
if(ans<nowmax){
ans=nowmax;
a=nowa;
b=i;
}
}
printf("Case %d:\n",case_++);
printf("%d %d %d\n",ans,a,b);
if(T!=) puts("");
}
return ;
}
/* 11
1 6
79 12 -22 -8 -2 -19 -7 5 -5 17 14 -22 7 -5 -13 -25 -24 21 12 10 13 12 22 20 -15 -12 -10 -15 -13 -17 14 2 -25 -22 11 -3 -15 18 23 15 8 -2 19 4 -18 -20 21 -1 1 19 20 -4 -9 5 -7 -19 9 20 -21 0 -22 -5 -13 15 0 -1 24 -17 8 8 -17 19 -4 -16 20 15 21 -11 -12 -23
67 -5 -23 24 21 11 6 21 11 -7 -25 -23 8 -7 5 -13 24 -24 13 1 -5 6 -11 -1 1 10 21 -9 -7 -15 -4 -25 7 -5 -3 11 20 16 7 14 7 -8 0 -23 -3 6 -24 8 -5 6 -22 -16 15 -19 -3 -1 -2 -2 20 24 -8 6 -19 -15 -25 -14 -25 13
17 1 -21 -14 13 -19 -18 -24 -21 -13 8 -2 -4 8 4 -4 -23 24
28 15 11 16 10 -16 -4 0 -25 -16 23 20 1 -7 -12 6 -20 -22 17 2 2 -23 -25 17 12 -21 6 -3 5
36 -6 22 1 -6 -5 1 5 -20 -15 -6 11 -5 -11 -10 3 16 20 -4 8 20 17 8 -7 9 -4 13 2 21 16 -20 -25 21 -13 3 -18 17
71 14 -22 24 -3 -4 14 -22 24 13 -22 -13 14 -4 20 -19 4 17 -9 0 -18 18 7 -19 -20 -22 -25 -16 -10 7 -15 -16 -17 -1 -7 22 -12 13 -14 8 -4 12 -16 -5 -4 17 -13 4 -21 -18 -8 -9 -13 -23 5 -25 -18 5 24 -14 5 -7 -24 -2 -12 24 -16 20 21 -2 -15 -11
64 -22 19 18 6 12 9 -5 10 -24 22 22 5 -3 -20 -21 18 24 3 9 7 13 -2 7 5 24 -12 6 -9 -10 12 -3 -21 -4 24 -7 -5 -8 22 -1 -16 -16 10 -11 -21 24 -3 3 -9 22 -7 6 -3 -6 6 23 -12 3 -17 -10 -9 -18 23 6 -9
71 17 10 -21 -10 -3 1 8 -21 16 -4 -23 -19 4 7 17 18 5 -25 -15 7 -2 -10 11 14 -11 -2 -11 11 14 20 19 -19 -18 7 -6 6 18 -20 12 -14 -6 -14 -13 -10 -23 -11 -24 9 6 -6 6 -25 8 14 -8 14 -17 2 -8 24 -11 -21 -18 5 6 4 -20 -11 3 -3 19
12 -25 -9 -20 5 15 15 -15 -10 -15 -17 -13 23
58 22 -20 -22 -25 1 -6 -7 -23 6 16 -17 -5 -23 -24 -9 -2 -16 23 7 14 16 19 -21 -5 6 10 -10 -23 0 -18 9 17 10 1 19 -23 15 7 -3 15 -17 -20 -23 22 -16 -1 -14 10 0 -17 2 -19 16 -6 -23 -25 -6 -12 */

[ An Ac a Day ^_^ ] hdu 1003 dp的更多相关文章

  1. hdu 4057 AC自己主动机+状态压缩dp

    http://acm.hdu.edu.cn/showproblem.php?pid=4057 Problem Description Dr. X is a biologist, who likes r ...

  2. HDU 1003(A - 最大子段和)

    HDU   1003(A - 最大子段和) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/A 题目: ...

  3. poj 1699 Best Sequence(AC自己主动机+如压力DP)

    id=1699" target="_blank" style="">题目链接:poj 1699 Best Sequence 题目大意:给定N个D ...

  4. hdu 1003 MAX SUM 简单的dp,测试样例之间输出空行

    测试样例之间输出空行,if(t>0) cout<<endl; 这样出最后一组测试样例之外,其它么每组测试样例之后都会输出一个空行. dp[i]表示以a[i]结尾的最大值,则:dp[i ...

  5. HDU 1003 Max Sum --- 经典DP

    HDU 1003    相关链接   HDU 1231题解 题目大意:给定序列个数n及n个数,求该序列的最大连续子序列的和,要求输出最大连续子序列的和以及子序列的首位位置 解题思路:经典DP,可以定义 ...

  6. HDU - 1003 Max Sum 【DP】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1003 题意 给出一个序列 要求找出一个和最大的子序列 思路 O(N)的做法 但是要标记 子序列的头部位 ...

  7. hdu 1003 hdu 1231 最大连续子序列【dp】

    HDU1003 HDU1231 题意自明.可能是真的进步了点,记得刚开始研究这个问题时还想了好长时间,hdu 1231还手推了很长时间,今天重新写干净利落就AC了. #include<iostr ...

  8. hdu 1003 Max sum(简单DP)

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem ...

  9. HDU 1003 Max Sum && HDU 1231 最大连续子序列 (DP)

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

随机推荐

  1. mysql 异常处理

    --该文章内容通过网络搜索组合, mysql 异常,可以自定义异常,再应用.也可使用系统默认的异常,捕获应用. 一.异常定义: DECLARE condition_name CONDITION FOR ...

  2. Tiny6410之UART裸机驱动

    UART简介: UART(Universal Asynchronous Receiver and Transmitter)通用异步收发器(异步串行通信口),是一种通用的数据通信协议,它包括了RS232 ...

  3. Mac OS启动服务优化高级篇(launchd tuning)

    Mac下的启动服务主要有三个地方可配置:1,系统偏好设置->帐户->登陆项2,/System/Library/StartupItems 和 /Library/StartupItems/3, ...

  4. PHP学习资源

    PHPerNote PHPerNote 是一个php程序员的工作生活笔记,本站包含了php网络编程学习教程,数据库(主要是MySQL数据库)教程,javascript,jquery,div+css,h ...

  5. Let's Encrypt(开源SSL证书管理工具)

    刚装上一个StartSSL 的证书没几天,却看到官方发出这样的通知: 无聊中看到了网上各种相关的扯淡: http://tieba.baidu.com/p/4801786642 http://www.t ...

  6. Spring Security(19)——对Acl的支持

    目录 1.1           准备工作 1.2           表功能介绍 1.2.1     表acl_sid 1.2.2     表acl_class 1.2.3     表acl_obj ...

  7. 给go添加各种package

    go version 1.1.2 For example you need to install the webscoket pakeage try           go get code.goo ...

  8. 366. Find Leaves of Binary Tree C#

    Example:Given binary tree 1 / \ 2 3 / \ 4 5 Returns [4, 5, 3], [2], [1]. Explanation: 1. Removing th ...

  9. 关于json和字符串之间的转换

    在最近的工作中,使用到JSON进行数据的传递,特别是从前端传递到后台,前台可以直接采用ajax的data函数,按json格式传递,后台Request即可,但有的时候,需要传递多个参数,后台使用requ ...

  10. [linux]查看机器有几个cpu,是否支持64位

    1. 查看物理CPU的个数#cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l 2. 查看逻辑CPU的个数#cat /pr ...