51nod 1049【经典】
2024-09-02 17:16:53
自己模拟,全靠体会~
#include <cstdio>
#include <stack>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=5e4+10;
LL a[N]; int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]); LL ans=a[1];
LL d=a[1];
for(int i=2;i<=n;i++)
{
if(d<0)
d=a[i];
else
d+=a[i];
if(d>ans)
ans=d;
}
printf("%lld\n",ans);
return 0;
}
最新文章
- Java演算法之堆排序(HeapSort)
- jQuery弹出窗口浏览图片
- sql 截取日期
- Java多线程系列--“JUC原子类”03之 AtomicLongArray原子类
- Apache2.2+php5.4在windows上配置实例
- Android中解析JSON格式数据常见方法合集
- 黑马程序员 Java基础<;九>;--->; 多线程
- linux 内核睡眠与唤醒
- web开发路径问题
- iOS极光推送SDK的使用流程
- [NOIP2002]字串变换 T2 双向BFS
- Linux 纯字符界面的玩法
- kubernetes系列07—Pod控制器详解
- java中去除字符串(String)中的换行字符(\r \n \t)
- bit、Byte、bps、Bps、pps、Gbps的单位详细说明及换算
- php 下载完成后删除文件
- FPGA中IBERT核的应用(转)
- QueryString to Dictionary<;string, string>;
- mongodb中Gson和java##Bean对象转化类
- java web程序启动加载 ContextLoaderListener