自己模拟,全靠体会~

#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;
}

51nod 1049【经典】的更多相关文章

  1. 51nod 1049 1049 最大子段和 (dp)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1049 令 dp[i]表示为以a[i]结尾的最大子段和,则  dp[i]= ...

  2. 51Nod 1049 最大子段和

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1049 #include<iostream> #i ...

  3. 51Nod 1049:最大子段和(dp)

    1049 最大子段和  基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 N个整数组成的序列a[1],a[2],a[3],-,a[n],求该序列如a[i]+ ...

  4. 51Nod 1049最大子段和 | 模板

    Input示例 6 -2 11 -4 13 -5 -2 Output示例 20 1.最大子段和模板 #include "bits/stdc++.h" using namespace ...

  5. (DP)51NOD 1049 最大子段和

    N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0.   例如:-2,11,-4,13,-5 ...

  6. 最大子段和 模板题 51Nod 1049

    N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0. 例如:-2,11,-4,13,-5,- ...

  7. 51nod 1412 AVL树的种类(经典dp)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1412 题意: 思路: 经典dp!!!可惜我想不到!! $dp[i][k] ...

  8. 51nod 1353 树 | 树形DP经典题!

    51nod 1353 树 | 树形DP好题! 题面 切断一棵树的任意条边,这棵树会变成一棵森林. 现要求森林中每棵树的节点个数不小于k,求有多少种切法. 数据范围:\(n \le 2000\). 题解 ...

  9. 51nod 1021 石子归并 - 区间dp(经典)

    题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1021 经典区间dp,dp[i][j] 表示将从 i 到 j 堆 ...

随机推荐

  1. php源码zend_do_begin_namespace函数详解

    version:5.6.21 file:Zend/zend_compile.c line:7055-7152 void zend_do_begin_namespace(const znode *nam ...

  2. C# 调用类库里的事件

    首先在类库中定义事件: //定义委托 public delegate void DelWeiTuo(string name); //定义事件 public event DelWeiTuo EventW ...

  3. ickeck插件

    地址:http://www.bootcss.com/p/icheck/#skins 使用 1. 先引入文件 css <link rel="stylesheet" type=& ...

  4. mybatis入门(七)

    mybatis入门--添加一个用户 //添加用户 @Test public void insertUserTest() throws IOException { // 通过工厂得到SqlSession ...

  5. PO 审批及生成xml文件

    *********************************************************************** * Report : YTST_RAINY_MM2 * ...

  6. JavaProject和IProject

    由 IProject 项目得到 Java 项目的方式: IJavaProject javaPoject = JavaCore.create(IProject); 由 IJavaProject 得到 I ...

  7. Go语言string,int,int64 ,float之间类型转换方法

    (1)int转string ? 1 2 s := strconv.Itoa(i) 等价于s := strconv.FormatInt(int64(i), 10) (2)int64转string ? 1 ...

  8. extjs grid renderer参数用法

    今天在导出EXT的二维时老是报错,追进去看是renderer : function(value)的参数不对,经过一番研究,未免以后遇到再次浪费时间,记录一下. var cm = new Ext.gri ...

  9. centos服务器安装配置Postgre9.6

    安装: STEP1:下载对应rpm yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64 ...

  10. Unable to resolve target 'android-16'

    Just now when I imported the "android-support-v7-appcompat" to ADT,the console pointed out ...