参考了一下 http://moxi466839201.blog.163.com/blog/static/18003841620110220374942/

滚动数组   状态转移方程不太好理解 ....  f[i][j]=max(f[i][j-1],f[i-1][j-1])+a[j];

#include<cstdio>
#include<cstring>
#include<iostream>
#define maxn 1000010
#define INF 1000000000
using namespace std; int dp[maxn],pre[maxn],a[maxn];
int main()
{
int n,m,_max;
while(scanf("%d%d",&m,&n) == 2)
{
memset(dp, 0, sizeof(dp));
memset(pre, 0, sizeof(pre));
for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
for(int i = 1; i <= m; i++)
{
_max = -INF;
for(int j = i; j <= n; j++)
{
dp[j] = max(dp[j-1], pre[j-1])+a[j];
pre[j-1] = _max;
_max = max(_max, dp[j]);
}
}
printf("%d\n",_max);
}
return 0;
}

hdu 1024的更多相关文章

  1. HDU 1024 max sum plus

    A - Max Sum Plus Plus Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  2. HDU 1024 Max Sum Plus Plus --- dp+滚动数组

    HDU 1024 题目大意:给定m和n以及n个数,求n个数的m个连续子系列的最大值,要求子序列不想交. 解题思路:<1>动态规划,定义状态dp[i][j]表示序列前j个数的i段子序列的值, ...

  3. 怒刷DP之 HDU 1024

    Max Sum Plus Plus Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  4. Max Sum Plus Plus HDU - 1024

    Max Sum Plus Plus     HDU - 1024 Now I think you have got an AC in Ignatius.L's "Max Sum" ...

  5. HDU 1024 Max Sum Plus Plus (动态规划)

    HDU 1024 Max Sum Plus Plus (动态规划) Description Now I think you have got an AC in Ignatius.L's "M ...

  6. HDU 1024:Max Sum Plus Plus(DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=1024 Max Sum Plus Plus Problem Description Now I think you ...

  7. HDU 1024 Max Sum Plus Plus【动态规划求最大M子段和详解 】

    Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  8. 动态规划 hdu 1024

    Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. (最大m子段和) Max Sum Plus Plus (Hdu 1024)

    http://acm.hdu.edu.cn/showproblem.php?pid=1024     Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/ ...

  10. HDU 1024 Max Sum Plus Plus(dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1024 题目大意:有多组输入,每组一行整数,开头两个数字m,n,接着有n个数字.要求在这n个数字上,m块 ...

随机推荐

  1. Asp.net中基于Forms验证的角色验证授权

    Asp.net的身份验证有有三种,分别是"Windows | Forms | Passport",其中又以Forms验证用的最多,也最灵活. Forms 验证方式对基于用户的验证授 ...

  2. contentProvider-联系人的CURD

    1.联系人的查找 返回一个ArrayList<HashMap<String,  String>>类型 //通过管理联系人的URI获取游标对象 Cursor cursor= ge ...

  3. AjaxPro使用方法

    无意中看到同事用AjaxPro用,看到很不错,特长是前后台传输数据特别方便. 最好的教材就是拿到就可以用,方便大家. 以前数据传输用FORM提交,或者在前台用JASON拼接然后通过AJAX方式提交.总 ...

  4. 使用edgesForExtendedLayout遇到的麻烦

    今天在写一个多界面之间来回返回的工程时,遇到的问题,建了两个类:FirstViewController 和 ButtonViewController. 由 FirstViewController 进入 ...

  5. 移植FastBlur模糊算法至SDL

    FastBlur是Android标配的模糊算法,这也在当时引起了一股毛玻璃热潮.IOS7就采用了此算法(这有抄袭Android之嫌,因为Android1.5就在标库中加入了此函数).算法效率很高,这也 ...

  6. [easyui] datebox源码阅读. 批注

    jquery.datebox.js 文件. (function($){ /** * create date box */ function createBox(target){ var state = ...

  7. maven中scope参数说明

    官方说明文档地址https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Depen ...

  8. Poj OpenJudge 百练 Bailian 1008 Maya Calendar

    1.Link: http://poj.org/problem?id=1008 http://bailian.openjudge.cn/practice/1008/ 2.content: Maya Ca ...

  9. IntelliJ IDEA 15.0.1配置jrebel6.5.2实现热部署

    网上查了很多,大多无效,写一下自己亲自实现的一种方法: 1. 官网下载Jrebel6.5.2版本的压缩包 2. 下载Jrebel6.5.2的破解文件:点击下载 3. 在intelliJ中添加插件(选择 ...

  10. HTML5之图形变换

    - Transformations scale(0.5,0.5) 缩放 rotate(0.175) 旋转 translate(100,50) 位移 - 代码结构 context.scale(x, y) ...