2017-09-06 21:32:22

writer:pprp

可以作为一个模板

/*
@theme: hdu1003 Max Sum
@writer:pprp
@end:21:26
@declare:连续区间最大和
@data:2017/9/6
*/ #include <bits/stdc++.h> using namespace std; int main()
{
//freopen("in.txt","r",stdin);
int cas;
cin >> cas;
for(int l = ; l <= cas; l++)
{
int n;
cin >> n;
int tmp = , ans = -, data2;
int op = , ed = , k = ; for(int i = ; i <= n ; i++)
{
cin >> data2;
tmp += data2; if(ans < tmp)//两个顺序不能调换,因为op这里要用上一个k
{
ans = tmp;
ed = i;
op = k;
} if(tmp < )
{
tmp = ;
k = i + ;
}
}
if(l != )
cout << endl; cout << "Case " << l << ":" << endl; cout << ans << " " << op << " " << ed << endl;
} return ;
}

解题报告:hdu1003 Max Sum - 最大连续区间和 - 计算开头和结尾的更多相关文章

  1. 杭电60题--part 1 HDU1003 Max Sum(DP 动态规划)

    最近想学DP,锻炼思维,记录一下自己踩到的坑,来写一波详细的结题报告,持续更新. 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 Problem ...

  2. HDU1003 Max Sum(求最大字段和)

    事实上这连续发表的三篇是一模一样的思路,我就厚颜无耻的再发一篇吧! 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 -------------- ...

  3. hdu1003 Max Sum(经典dp )

      A - 最大子段和 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descr ...

  4. HDU--1003 Max Sum(最大连续子序列和)

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

  5. HDU-1003 Max Sum(动态规划,最长字段和问题)

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

  6. [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 ...

  7. ACM学习历程—HDU1003 Max Sum(dp && 最大子序列和)

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

  8. hdu1003 Max Sum【最大连续子序列之和】

    题目链接:https://vjudge.net/problem/HDU-1003 题目大意:给出一段序列,求出最大连续子序列之和,以及给出这段子序列的起点和终点. 解题思路:最长连续子序列之和问题其实 ...

  9. 最大子序列和——HDU-1003 Max Sum

    题目大意:给定序列个数n及n个数,求该序列的最大连续子序列的和,要求输出最大连续子序列的和以及子序列的首位位置 解题思路:经典DP,可以定义dp[i]表示以a[i]为结尾的子序列的和的最大值,因而最大 ...

随机推荐

  1. TestLink安装手册

    环境准备 系统CentOS Linux release 7.3.1611 (Core) 搭建LAMP所需的集成包 xampp-linux-x64-7.2.0-0-installer.run 下载地址 ...

  2. app后端设计(0)--总目录(转)

    原文:http://blog.csdn.net/newjueqi/article/details/19003775 做了接近两年app相关的系统架构,api设计,先后在两个创业公司中工作,经历过手机网 ...

  3. python pip命令技巧

    确保本地开发环境,和线上一致性 1.导出当前解释器的模块pip3 freeze > requirements.txt 2.将这个文件requirements.txt,上传至服务器,在新的虚拟环境 ...

  4. VMware 虚拟机 Ubuntu 不能全屏问题

    在刚安装完ubuntu后,屏幕不能全屏显示,此时: 1.安装VMware Tools 步骤: 1.1     进入ubuntu系统后,点击虚拟机上的[虚拟机]->[安装 vmware tools ...

  5. python学习笔记(十八)网络编程之requests模块

    上篇博客中我们使用python自带的urllib模块去请求一个网站,或者接口,但是urllib模块太麻烦了,传参数的话,都得是bytes类型,返回数据也是bytes类型,还得解码,想直接把返回结果拿出 ...

  6. mysql相关配置

    http://www.cnblogs.com/cnblogsfans/archive/2009/09/21/1570942.html http://www.jb51.net/article/31902 ...

  7. java通过url抓取网页数据

    在很多行业中,要对行业数据进行分类汇总,及时分析行业数据,对于公司未来的发展,有很好的参照和横向对比.所以,在实际工作,我们可能要遇到数据采集这个概念,数据采集的最终目的就是要获得数据,提取有用的数据 ...

  8. node+express+http-proxy-middleware做代理

    最近,不赶着做项目,于是想着怎样做公司的前后端分离,这个时候想到了nodejs,于是打算今天做一个代理的demo,其实代码很简单,但是一直卡在一个地方,现在问题解决了,贴上代码和截图. html &l ...

  9. Delphi APP 開發入門(八)SQLite資料庫

    Delphi APP 開發入門(八)SQLite資料庫 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次 ...

  10. Django:学习笔记(9)——用户身份认证

    Django:学习笔记(9)——用户身份认证 User