HDU - 1087 Super Jumping! Jumping! Jumping!(dp)
题意:从起点依次跳跃带有数字的点直到终点,要求跳跃点上的数字严格递增,问跳跃点的最大数字和。
分析:
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)的更多相关文章
- HDU 1024 Max Sum Plus Plus(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1024 题目大意:有多组输入,每组一行整数,开头两个数字m,n,接着有n个数字.要求在这n个数字上,m块 ...
- HDU 1203 I NEED A OFFER!(dp)
Problem Description Speakless很长时间,我想出国.现在,他已经完成了所有需要的检查.准备好所有要准备的材料,于是,便须要去申请学校了.要申请国外的不论什么大学.你都要交纳一 ...
- HDU 1231:最大连续子序列(DP)
pid=1231">最大连续子序列 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- HDU 1069:Monkey and Banana(DP)
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 【HDU 6017】 Girls Love 233 (DP)
Girls Love 233 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- 2017百度之星资格赛 1003:度度熊与邪恶大魔王(DP)
.navbar-nav > li.active > a { background-image: none; background-color: #058; } .navbar-invers ...
- HDU6578 2019HDU多校训练赛第一场 1001 (dp)
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...
- LightOJ 1033 Generating Palindromes(dp)
LightOJ 1033 Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- lightOJ 1047 Neighbor House (DP)
lightOJ 1047 Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730# ...
随机推荐
- [转]Java——Servlet的配置和测试
本文转自:http://blog.csdn.net/makefish/article/details/6904807 本文以一个实例介绍如何用Java开发Servlet. 主要内容有: 配置和验证To ...
- a链接 打电话 发短信 发email
<a href="tel:10086">给10086打电话</a><a href="sms:10086">给10086发短信 ...
- git - 节点树理解
1.如下图 最左边黑色线是当前分支节点 每个点代表一次提交 2.当执行merge prd的时候 会把其他分支的节点都merge到你的分支同时产生右边的每条节点线. 3.每个版本都会与某条版本线上的一个 ...
- python基础day05
上节内容变量if else注释 # ''' msg ''' 3个引号 打印多行 ', "" 双单引号的意义是一样的 缩进 本节内容pycharm使用 集成开发环境(IDE,Inte ...
- yii 框架 – 安全站点和非安全站点的 URL 管理
在本文中我将描述怎么管理安全站点和非安全站点的 URL 管理. 安全站点的内容使用httpsSSL (安全套接字层) 协议发送,而非安全站点使用http协议.为了描述简单,我们称前者https内容/页 ...
- UGUI 特效怎样在UI上裁剪
刚好碰到有人问怎样把粒子特效放到 UI 上并且能正确被 Mask 裁剪, 首先想到给粒子效果的 Shader 添加模板模仿一般 UI 的模板方式, 应该就能正确裁剪了吧, 不过没那么简单, 我们看到在 ...
- js获取video的播放时长
setTimeout(function () { var vid = document.getElementById("videoIntro"); var currentTim ...
- Mybatis(使用)与Spring整合
1.总结 https://pan.baidu.com/s/1kWpz7ZD 密码:tsvr 2.代码 https://pan.baidu.com/s/1mjgAeak 密码:h9j8 3.资料 ...
- HashSet原理
- 2020.2.19 restful的学习
restful Api 设计要素 3-8 如何设计Restful Api 资源路径(url),HTTP动词,过滤信息(做分页),状态码,错误处理,返回结果 3-9 初始化运行参数 3-10 ...