题意:从起点依次跳跃带有数字的点直到终点,要求跳跃点上的数字严格递增,问跳跃点的最大数字和。

分析:

1、若之前的点比该点数字小,则可进行状态转移,dp[i] = max(dp[i], dp[j] + a[i]);

2、dp[i]---截止到i,跳跃的最大数字和。

3、由于不确定最终是哪个点直接跳往终点可保证数字和最大,因此,扫一遍,ans = max(ans, dp[i]);

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 1000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
int a[MAXN];
int dp[MAXN];
int main(){
int N;
while(scanf("%d", &N) == 1){
if(N == 0) return 0;
memset(dp, 0, sizeof dp);
for(int i = 1; i <= N; ++i){
scanf("%d", &a[i]);
}
for(int i = 1; i <= N; ++i){
dp[i] = a[i];
for(int j = 1; j <= i - 1; ++j){
if(a[j] < a[i]){
dp[i] = max(dp[i], dp[j] + a[i]);
}
}
}
int ans = 0;
for(int i = 1; i <= N; ++i){
ans = max(ans, dp[i]);
}
printf("%d\n", ans);
}
return 0;
}

  

HDU - 1087 Super Jumping! Jumping! Jumping!(dp)的更多相关文章

  1. HDU 1024 Max Sum Plus Plus(dp)

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

  2. HDU 1203 I NEED A OFFER!(dp)

    Problem Description Speakless很长时间,我想出国.现在,他已经完成了所有需要的检查.准备好所有要准备的材料,于是,便须要去申请学校了.要申请国外的不论什么大学.你都要交纳一 ...

  3. HDU 1231:最大连续子序列(DP)

    pid=1231">最大连续子序列 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Jav ...

  4. HDU 1069:Monkey and Banana(DP)

    Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  5. 【HDU 6017】 Girls Love 233 (DP)

    Girls Love 233 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  6. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...

  7. 2017百度之星资格赛 1003:度度熊与邪恶大魔王(DP)

    .navbar-nav > li.active > a { background-image: none; background-color: #058; } .navbar-invers ...

  8. HDU6578 2019HDU多校训练赛第一场 1001 (dp)

    HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...

  9. LightOJ 1033 Generating Palindromes(dp)

    LightOJ 1033  Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  10. lightOJ 1047 Neighbor House (DP)

    lightOJ 1047   Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730# ...

随机推荐

  1. free to monitor your sqlserver easy and safe and ...

    Unlike AWR in Oracle, Sqlserver does not have offical way to make history performance information fo ...

  2. ABC155D - Pairs

    本题的模型是典型的求第k小问题,这个问题有2个不一样的点,一是任意选出2个数,不能是同一个,二是这个题有负数,那我们在原有的基础上就需要特判这两点,经典模型是2个数组相乘,此处是1个,那么一样可以枚举 ...

  3. LTE 网元功能

    E-NodeB : 无线资源管理,无线承载控制.无线接入控制.连接移动性控制.UE的上下行动态资源分配 IP头压缩及用户数据流加密 UE连接期间选择MME 路由用户面数据至S-GW 寻呼消息的组织和发 ...

  4. linux查漏补缺-Linux文件目录结构一览表

    FHS 标准 FHS(Filesystem Hierarchy Standard),文件系统层次化标准,该标准规定了 Linux 系统中所有一级目录以及部分二级目录(/usr 和 /var)的用途. ...

  5. Python 数据的输入

    一.单个输入 a=input("输入提示语句")#默认a的类型是字符串 b=input() 二.一行输入两个/三个数据,数据之间用空格间隔开 #a,b的数据类型都是整数 a,b=m ...

  6. 2017 青岛现场赛 Suffix

    Consider n given non-empty strings denoted by s1 , s2 , · · · , sn . Now for each of them, you need ...

  7. ubuntu 12.04 配置vsftpd 服务,添加虚拟用户,ssl加密

    1.对于12.04的vsftpd 有一些bug,推荐安装版本vsftpd_2.3.5-1ubuntu2ppa1_amd64.debapt-get install python-software-pro ...

  8. css 盒子模型应用

    盒子模型应用 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...

  9. SQL 笔记1,left join,group by,having

    表:XS,XK,CJ left join 表1 on 表1.字段=表2.字段 group by 分组条件 order by 排序条件 asc正序(小到大),desc倒序 having 跟条件类似whe ...

  10. java web开发缓存方案,ehcache和redis哪个更好

    Ehcache在java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS中取出来的高花费.高延迟采取的一种缓存方案.正因为Ehcache具有健壮性(基于java开发).被认证(具有apac ...