Poj 2593 动态规划 Max Squence
来源:互联网 发布:商城app源码 编辑:程序博客网 时间:2024/05/21 03:26
http://poj.org/problem?id=2593
http://www.cnblogs.com/devil-91/archive/2012/08/06/2625765.html
#include<stdio.h>#include <memory.h>#include<iostream>using namespace std;void run(){int left[100005];int right[100005];int a[100005];while(1){int n,i;scanf("%d",&n);if(n==0)break;for(i=0;i<n;i++)scanf("%d",&a[i]);int sumL=0;int max=-999999;for(i=0;i<n;i++){sumL=sumL+a[i];if(sumL>max)//注意 if(sumL>max)和if(sumL<0)不能交换max=sumL;if(sumL<0)sumL=0;left[i]=max;}max=-999999;int tmp=-999999;int sumR=0;for(i=n-1;i>=1;i--){sumR=sumR+a[i];if(sumR>max)max=sumR;if(sumR<0)sumR=0;if(tmp<max+left[i-1])tmp=max+left[i-1];}printf("%d\n",tmp);}}int main(){run();return 0;}
- Poj 2593 动态规划 Max Squence
- POJ 1050-To the Max (动态规划)
- POJ 1050 To the Max -- 动态规划
- 【动态规划】[POJ 1050]To the Max
- 动态规划----SPOJ 1182. Sorted bit squence (数位统计+二分)
- [ACM] POJ 2593 Max Sequence (动态规划,最大字段和)
- poj 动态规划之1050 To the Max
- Max Sum(动态规划)
- poj 1019 Number Squence
- poj 1141 Brackets Squence
- hdu1081To The Max【动态规划】
- 动态规划之MAX Sum
- 动态规划hdu Max Sum
- Max Sum (简单动态规划)
- hdu1003 Max Sum(动态规划)
- HDU1003 max sum 动态规划?
- To The Max(动态规划)
- 【动态规划】HDU1081To The Max
- 黑马程序员---交通灯管理系统【java】
- java中静态代码块的用法
- Objective-c中类的定义
- 高仿酷狗音乐的卡拉OK的字幕效果
- 现在的问题
- Poj 2593 动态规划 Max Squence
- 双边滤波(bilateral filtering)
- 新建 ProvinceCity用户控件。在该控件 中增加一个Button1按钮
- 云存储网关(cloud storage gateway)
- struts2之s:radio分行显示问题
- 在Linux环境上安装memcached手册
- AI会议的总结(by南大周志华)
- Windows 远程访问oralce 问题 ora-12560
- struts2中 # % $ (井号,星号,百分号)的区别和用法