51nod 1050 循环数组最大子段和
来源:互联网 发布:python如何做抢票软件 编辑:程序博客网 时间:2024/05/23 02:26
#include <bits/stdc++.h>using namespace std;long long a[50050],sum[50050];int main(){long long n,i,ans,mnsum,mxsum;while(cin>>n){sum[0]=0;for(i=1;i<=n;i++){scanf("%lld",&a[i]);sum[i]=sum[i-1]+a[i];}ans=0;mnsum=0;mxsum=-(1<<30);for(i=1;i<=n;i++){ans=max(ans,sum[i]-mnsum);ans=max(ans,sum[n]-sum[i]+mxsum);mnsum=min(mnsum,sum[i]);mxsum=max(mxsum,sum[i]);} printf("%lld\n",ans);}}
0 0
- 【循环数组最大子段和】51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和 dp
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod-1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51Nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51Nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- 51nod 1050 循环数组的最大子段和
- 51NOD 1050 循环数组最大子段和
- 51nod 1050 循环数组最大子段和
- xcode 卡顿问题
- 基于原生JavaScript进行扩展模拟用户长按事件(webapp)
- 9 signaling at the nerve-muscle synapse: directly gated transmission
- Oracle to_char格式化函数
- ubuntu安装配置FTP
- 51nod 1050 循环数组最大子段和
- jQuery的each、siblings的基本使用和jQ常见错误
- VC++编译说明
- [转]swift 计算年龄,No "|" candidates produce the expected contextual result
- EditText自定义监听方法实现onFocusChanged的监听
- Android字体大小多屏幕适配
- Activity透明设置,且可以实现无标题,亲测可用
- 第26节--层次聚类(上)
- SpringMVC+MyBatis 返回时间格式转换的解决方案