A - Super Jumping! Jumping! Jumping!

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.

InputInput 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.
OutputFor 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
 题目大意:求升序子序列的最大和
 #include<bits/stdc++.h>
using namespace std; int dp[];//dp用于存放从数组头到此为止的最大升序子序列和
int n, a[];
int maxn; int main(){
while(~scanf("%d", &n) && n){
maxn = ;
for(int i=; i<n; i++){
scanf("%d", a+i);
dp[i] = a[i];//将每个ai的值赋予dpi
}
for(int i=; i<n; i++){
for(int j=; j<i; j++){
if(a[i] > a[j] && dp[i] < dp[j]+a[i])
dp[i] = dp[j] + a[i];
if(dp[i] > maxn) maxn = dp[i];
}
} printf("%d\n",maxn);
}
}

是今天刚学的dp,告诉我们这类题目没有固定的模板,更重要的是思维和思考,借助dp这样的一个数组,去存放你需要求或相关的变量。既然没有固定模板,则需要更多的练习,去接触更多样式的巧妙的题目

dp --A - Super Jumping! Jumping! Jumping!的更多相关文章

  1. HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)

    传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...

  2. DP专题训练之HDU 1087 Super Jumping!

    Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...

  3. hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  4. HDU 1087 Super Jumping! Jumping! Jumping! (DP)

    C - Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format: ...

  5. HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)

    Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...

  6. Super Jumping! Jumping! Jumping!(dp)

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  7. HDU1087:Super Jumping! Jumping! Jumping!(DP)

    Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...

  8. Super Jumping! Jumping! Jumping! 基础DP

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  9. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...

随机推荐

  1. python 函数3(模块)

    1.将函数存储在模块中 1.1.导入整个模块 要将函数导入,得先创建模块,模块 是扩展名为.py的文件,包含要导入到程序中的代码. 首先定义编写一个.py的文件,命名为pizza.py,代码如下: d ...

  2. CCF_ 201403-4_无线网络

    分散点的bfs,先建立一个互相是否可达的二维数组,vis[i][j]代表到第i个点,走了j步的状态,注意判断新增路由器数量是否超过K. #include<cstdio> #include& ...

  3. 最简单的windows 10 软路由

    因为轻信了 小米路由器3潘多拉固件刷机教程 年前把自己的小米路由器3pro 刷程砖了,然后自己有一台 i5256 的三众小主机,连在电信光猫上,可以拨号,勉强可以用,but 家里的设备那么多尤其手机笔 ...

  4. AppBox实战: 如何实现一对多表单的增删改查

      本篇通过完整示例介绍如何实现一对多关系表单的相应服务及视图. 一.准备数据结构   示例所采用的数据结构为"物资需求"一对多"物资清单",通过IDE的实体设 ...

  5. Gorm与数据库(单复数)表结构之间的映射

    Gorm连接MySQL: import ( _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ...

  6. DOM - Document Object Model

    Document Object Model

  7. Rust入坑指南:步步为营

    俗话说:"测试写得好,奖金少不了." 有经验的开发人员通常会通过单元测试来保证代码基本逻辑的正确性.如果你是一名新手开发者,并且还没体会到单元测试的好处,那么建议你先读一下我之前的 ...

  8. windows、linux 下启用mysql日志功能

    在默认情况下,mysql安装是没有启用日志管理功能的,这为后续的维护带来很多不便的地方. 查看是否启用了日志mysql>show variables like 'log_bin'; 怎样知道当前 ...

  9. css3 动画 示例

    /* animation */ .a-bounce,.a-flip,.a-flash,.a-shake,.a-swing,.a-wobble,.a-ring{-webkit-animation:1s ...

  10. javascirpt获取随机数

    /* getran(min, max, n): 获取min与max之间的随机数 n: n保留浮点数数量 */ function getran(min, max, n){ return Number(( ...