DP专题训练之HDU 1087 Super Jumping!
Description
The
game can be played by two or more than two players. It consists of a
chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a
positive integer or “start” or “end”. The player starts from start-point
and must jumps into end-point finally. In the course of jumping, the
player will visit the chessmen in the path, but everyone must jumps from
one chessman to another absolutely bigger (you can assume start-point
is a minimum and end-point is a maximum.). And all players cannot go
backwards. One jumping can go from a chessman to next, also can go
across many chessmen, and even you can straightly get to end-point from
start-point. Of course you get zero point in this situation. A player is
a winner if and only if he can get a bigger score according to his
jumping solution. Note that your score comes from the sum of value on
the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.
Input
N value_1 value_2 …value_N
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.
Output
Sample Input
Sample Output
求最大递增序列和~(不要求连续。。)
看样例我以为是求最大连续递增序列和的说~~
//Asimple
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#include <time.h>
#define INF 0xfffffff
#define mod 1000000
#define swap(a,b,t) t = a, a = b, b = t
#define CLS(a, v) memset(a, v, sizeof(a))
#define debug(a) cout << #a << " = " << a <<endl
#define abs(x) x<0?-x:x
#define srd(a) scanf("%d", &a)
#define src(a) scanf("%c", &a)
#define srs(a) scanf("%s", a)
#define srdd(a,b) scanf("%d %d",&a, &b)
#define srddd(a,b,c) scanf("%d %d %d",&a, &b, &c)
#define prd(a) printf("%d\n", a)
#define prdd(a,b) printf("%d %d\n",a, b)
#define prs(a) printf("%s\n", a)
#define prc(a) printf("%c", a)
using namespace std;
typedef long long ll;
const int maxn = ;
int n, m, num, T, k, len, ans, sum;
int dp[maxn], a[maxn]; //不一定连续~~~
void input() {
while( ~srd(n) && n ) {
for(int i=; i<n; i++) {
srd(a[i]);
}
CLS(dp, );
dp[] = a[];
for(int i=; i<n; i++) {
for(int j=; j<i; j++) {
if( a[i] > a[j])
dp[i] = max(dp[i], dp[j]+a[i]);
}
dp[i] = max(dp[i], a[i]);
}
ans = ;
for(int i=; i<n; i++) {
ans = max(ans, dp[i]);
}
prd(ans);
}
} int main(){
input();
return ;
}
DP专题训练之HDU 1087 Super Jumping!的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP)
C - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- HDU 1087 Super Jumping! Jumping! Jumping!【DP】
解题思路:题目的大意是给出一列数,求这列数里面最长递增数列的和 dp[i]表示到达地点i的最大值,那么是如何达到i的呢,则我们可以考虑没有限制条件时候的跳跃,即可以从第1,2,3,---,i-1个地点 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- robot创建桌面图标(转载)
桌面ride图标,安装之后会自动创建(偶尔也会创建失败),创建桌面图标方法如下: 1. 新建快捷方式 在桌面右击鼠标,弹出的菜单选择 新建-快捷方式 ,然后在"请键入对象"的位置输 ...
- JavaScript自学之数组排序
<html> <head> <title>数组排序</title> <script type="text/javascript" ...
- Android 操作系统的内存回收机制(转载)
Android 操作系统的内存回收机制(转载) Android APP 的运行环境 Android 是一款基于 Linux 内核,面向移动终端的操作系统.为适应其作为移动平台操作系统的特殊需要,谷歌对 ...
- php 登录注册api接口代码
/** *一览(www.yl1001.com) * PHP开发API接口 服务端 */ require 'conn.php'; //连接数据库的文件 header('Content-Type:text ...
- Javascript基础知识总结一
Javascript基础知识总结一 <!DOCTYPE html> <html> <head lang="en"> <meta chars ...
- web前端开发学习路径图
第一阶段 WEB前端工程师课程 HTML语句,HTML页面结构.css语法.style属性.link和style标签.id属性.等HTML语句中的相关属性: 通过Dreamweaver制作出跨越平台限 ...
- Android 基于Android的手机邮件收发(JavaMail)之三(邮件接收)
初次做这个程序的时候,是仿照着网上别人的程序做的.因为本人比较菜,是一个新手,以前的基础知识没有学好,所以尽管有了别人的代码但是还是不知道怎么在界面上显示出它的效果来,废话不多少,现在就贴出我的参考程 ...
- 奥威软件Speed-BI荣获2016年度中国大数据最佳云平台奖
(原文转自:http://www.powerbi.com.cn/page110?article_id=210) 2016年12月16日,“科技原力觉醒,引领创新巅峰”—2016创新影响力年会暨国家产业 ...
- GCD的简单用法
/* 创建一个队列用来执行任务,TA属于系统预定义的并行队列即全局队列,目前系统预定义了四个不同运行优先级的全局队列,我们可以通过dispatch_get_global_queue来获取它们 四种优先 ...
- centos7 web服务器内核优化
net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_keepalive_time = 600net.ipv4 ...