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

 #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. ECMAScript6之Array类型的扩展

    数组的扩展 Array.of() 将一组值转换成数组 Array.of(1,2,3,4,5); //[1,2,3,4,5] Array.from() 可将类似数组的对象或者可便利的对象转换成数组,比如 ...

  2. python之实现缓存环

    看了CodeBokk 第二版通过python实现缓存环,吸收之后记录下,方便以后查阅. 任务: 定义一个固定尺寸的缓存,当它填满的时候,新加入的元素会覆盖第一个(最老的)元素.这种数据结构在存储日志和 ...

  3. StringBuffer使用append提示String concatenation as argument to 'StringBuffer.append()' call

    昨天发现一个IDE提示: String concatenation as argument to 'StringBuffer.append()' call less... (Ctrl+F1) Repo ...

  4. Jasper_style

    (1) text field <style name="Header" forecolor="#FFFFFF" backcolor="#002D ...

  5. CSS 待解决问题

    记录一些待解决的问题 1. 关于 table 边框参差不齐问题 乍一看表头的边框有 间隙, 下边框也有点没有对其的问题. 解决方案:  给 table 添加: border-collapse: col ...

  6. Python学习笔记——基础篇【第六周】——PyYAML & configparser模块

    PyYAML模块 Python也可以很容易的处理ymal文档格式,只不过需要安装一个模块,参考文档:http://pyyaml.org/wiki/PyYAMLDocumentation 常用模块之Co ...

  7. HDU 1040 As Easy As A+B(排序)

    As Easy As A+B Problem Description These days, I am thinking about a question, how can I get a probl ...

  8. centos7.0 vsftp配置

    7.0版本 1.安装 yum -y install vsftpd 2.配置 vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO //设定不允许匿名访问 loc ...

  9. python 内嵌函数, 闭包, 函数装饰器

    一.  函数内嵌 闭包 在python中,函数可以作为返回值, 可以给变量赋值. 在python中, 内置函数必须被显示的调用, 否则不会执行. #!/usr/bin/env python #-*- ...

  10. 向多个会话窗口发送命令 -SecureCRT

    1.前提 一个服务可能部署在多台机器上,这时如果要查问题,最繁复的方法就是打开该服务的每个session,把命令在每一台机器上复制一下执行,找到相关的日志:还有一种方法就是一条命令同时向多个会话窗口发 ...