Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31490    Accepted Submission(s): 14146

Problem Description
Nowadays,
a kind of chess game called “Super Jumping! Jumping! Jumping!” is very
popular in HDU. Maybe you are a good boy, and know little about this
game, so I introduce it to you now.

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
Input contains multiple test cases. Each test case is described in a line as follow:
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
For each case, print the maximum according to rules, and one line one case.
 
Sample Input
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
 
Sample Output
4
10
3
DP水题。。。
 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = ;
int a[maxn];
long long dp[maxn];
void solve(){
int n;
while(scanf("%d",&n)!=EOF&&n){
for(int i = ; i<=n; i++) scanf("%d",&a[i]);
memset(dp,,sizeof(dp));
long long ans = ;
for(int i = ; i<=n; i++){
dp[i] = a[i];
for(int j = ; j<=i; j++){
if(a[i]>a[j]){
dp[i] = max(dp[i],dp[j]+a[i]);
}
}
ans = max(ans,dp[i]);
}
printf("%I64d\n",ans);
}
}
int main()
{
solve();
return ;
}

Super Jumping! Jumping! Jumping! 基础DP的更多相关文章

  1. 「kuangbin带你飞」专题十二 基础DP

    layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathj ...

  2. 基础dp

    队友的建议,让我去学一学kuangbin的基础dp,在这里小小的整理总结一下吧. 首先我感觉自己还远远不够称为一个dp选手,一是这些题目还远不够,二是定义状态的经验不足.不过这些题目让我在一定程度上加 ...

  3. 基础DP(初级版)

    本文主要内容为基础DP,内容来源为<算法导论>,总结不易,转载请注明出处. 后续会更新出kuanbin关于基础DP的题目...... 动态规划: 动态规划用于子问题重叠的情况,即不同的子问 ...

  4. hdu 5586 Sum 基础dp

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Desc ...

  5. hdu 4055 Number String (基础dp)

    Number String Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. 训练指南 UVA - 10917(最短路Dijkstra + 基础DP)

    layout: post title: 训练指南 UVA - 10917(最短路Dijkstra + 基础DP) author: "luowentaoaa" catalog: tr ...

  7. 训练指南 UVA - 11324(双连通分量 + 缩点+ 基础DP)

    layout: post title: 训练指南 UVA - 11324(双连通分量 + 缩点+ 基础DP) author: "luowentaoaa" catalog: true ...

  8. M - 基础DP

    M - 基础DP Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Descriptio ...

  9. lightoj1004【基础DP】

    从低端到顶端求个最大值: 思路: 基础DP,递推 #include<cstdio> #include<queue> #include<map> #include&l ...

随机推荐

  1. hdu_1848_Fibonacci again and again(博弈sg函数)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 题意:给你3堆石子,每次只能取fibonacci数的石子,问先手是否能赢 题解:SG函数模版题 ...

  2. hdu_4714_Tree2cycle(树形DP)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意:给你N个点N-1条边,形成一个树,让你拆树,并连接成一个环,每拆一次,连接一次,消耗1,问 ...

  3. 找最大重复次数的数和重复次数(C++ Pair)

    Problem A: 第一集 你好,世界冠军 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 265  Solved: 50[Submit][Statu ...

  4. Linux基础命令---压缩与打包

    GZIP: 普通文件打包成gzip文件:gzip filename(问题:如何测试一个文件是否是gzip文件?) gzip文件解压成普通文件:gzip -d filename(副作用:原始gz文件会被 ...

  5. TextBox只读时不能通过后台赋值取值解决办法

    给页面的TextBox设置ReadOnly="True"时,在后台代码中不能赋值取值,下边几种方法可以避免:  1.不设置ReadOnly,设置onfocus=this.blur( ...

  6. 避免IE执行AJAX时,返回JSON出现下载文件

    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.conv ...

  7. 编译安装SVN不结合apache

    前言:独立SVN服务器不结合APACHE安装使用,连接独立SVN服务器也不是用HTTP协议.这是比较快捷的SVN服务器配置方法. 一.下载工具 1.subversion-1.6.17.tar.gz 2 ...

  8. Python 线程,进程

    Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元 线程不能实现多并发 只能实现伪并发 每次工作 只能是一个线程完成 由于python解释器 原生是c  原生线程 底层都会有一把 ...

  9. c++11 对象池的实现

    ; template <typename T> class ObjectPool { template <typename... Args> using Constructor ...

  10. 【同一直线最多点】 poj 1118+2606+2780

    poj 1118 #include<iostream> using namespace std; #define N 700 struct point {int x,y;} pnt[N]; ...