poj 2479
来源:互联网 发布:贝克汉姆维多利亚知乎 编辑:程序博客网 时间:2024/06/06 20:06
#include <cstdio>const int M=50010;int p[M], a[M], b[M];int max(int a, int b){ return a>b?a:b;}int main(){ // freopen("in","r",stdin); // freopen("out","w",stdout); int i,t,n; scanf("%d",&t); while( t-- ) { scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&p[i]); a[0]=p[0]; for(i=1;i<n;i++) { if( a[i-1]<0 ) a[i]=p[i]; else a[i]=a[i-1]+p[i]; } for(i=1;i<n;i++) a[i]=max(a[i-1],a[i]); b[n-1]=p[n-1]; for(i=n-2;i>=0;i--) { if( b[i+1]<0 ) b[i]=p[i]; else b[i]=b[i+1]+p[i]; } for(i=n-2;i>=0;i--) b[i]=max(b[i+1],b[i]); int ans=-1000000000; for(i=0;i<n-1;i++) ans=max(ans,a[i]+b[i+1]); printf("%d\n",ans); } return 0;}
0 0
- POJ 2479
- POJ 2479
- poj 2479
- POJ 2479
- POJ 2479
- poj 2479
- POJ 2479
- POJ 2479
- poj 2479
- poj 2479
- poj 2479
- POJ 2479
- POJ 2479
- poj 2479
- poj 2593 与 poj 2479
- POJ 2479 和 POJ 2593
- poj 2593 & poj 2479解题报告
- poj 2479解题报告
- 重装linux服务器简易流程
- Java中类加载器的理解
- org.hibernate.LazyInitializationException: could not initialize proxy - no Session
- hibernate+spring的整合思路加实例
- 面试知识:操作系统、计算机网络、设计模式、Linux编程,数据结构总结
- poj 2479
- CoCos2Dx学习笔记之环境配置
- 设置Windows 8.1屏幕自动旋转代码, Auto-rotate function code
- leetcode做题总结,题目Plus One 2012/04/02
- hdoj 2098 分拆素数和
- adboost
- 38_抖动的动画效果&动画的插入器
- bzoj1615 [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机
- 【HDU】4873 ZCC Loves Intersection 数学