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
 
要用两个数组。。。
#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 1100
int main()
{
int n,a[N],b[N],i,j;
while(scanf("%d",&n),n)
{
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
b[i]=a[i];
}
for(i=;i<n;i++)
{
for(j=;j<i;j++)
{
if(a[j]<a[i]&&b[i]<a[i]+b[j])
b[i]=a[i]+b[j];
}
}
int maxn=;
for(i=;i<n;i++)
{
if(maxn<b[i])
maxn=b[i];
}
printf("%d\n",maxn);
}
return ;
}

动态规划:HDU1087Super Jumping! Jumping! Jumping!(最大上升和)的更多相关文章

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

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

  2. 【动态规划】矩形嵌套 (DGA上的动态规划)

    [动态规划]矩形嵌套 时间限制: 1 Sec  内存限制: 128 MB提交: 23  解决: 9[提交][状态][讨论版] 题目描述 有n个矩形,每个矩形可以用a,b来描述,表示长和宽.矩形X(a, ...

  3. 【CF1097E】Egor and an RPG game(动态规划,贪心)

    [CF1097E]Egor and an RPG game(动态规划,贪心) 题面 洛谷 CodeForces 给定一个长度为\(n\)的排列\(a\),定义\(f(n)\)为将一个任意一个长度为\( ...

  4. 树型动态规划(树形dp)

    树型动态规划就是在“树”的数据结构上的动态规划,树型动态规划是建立在树上的,所以有二个方向: 1.根—>叶:这种题目基本上碰不到 2.叶->根:根的子节点传递有用的信息给根,完后根得出最优 ...

  5. 算法-动态规划 Dynamic Programming--从菜鸟到老鸟

    算法-动态规划 Dynamic Programming--从菜鸟到老鸟      版权声明:本文为博主原创文章,转载请标明出处. https://blog.csdn.net/u013309870/ar ...

  6. Luogu 2540 斗地主增强版(搜索,动态规划)

    Luogu 2540 斗地主增强版(搜索,动态规划) Description 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来进行的扑克牌游 ...

  7. Luogu 2668 NOIP 2015 斗地主(搜索,动态规划)

    Luogu 2668 NOIP 2015 斗地主(搜索,动态规划) Description 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来 ...

  8. 动态规划入门——数字三角形(Java)

    动态规划的概念对于新手来说枯燥难懂,就算看懂了,做题的时候依旧抓耳挠腮的毫无头绪,这些比较难理解的算法,还是需要根据例子来一步步学习和理解,从而熟练掌握,下面,咱们就通过一个简单的小例子来学习动态规划 ...

  9. Luogu 1063 能量项链(动态规划)

    Luogu 1063 能量项链(动态规划) Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某 ...

随机推荐

  1. iPhone4 offical AD

    iPhone4 is so much more than just a new products.I mean this would have a lot of impact on the way i ...

  2. $("xxx").attr添加属性的时候不好用

    今天在工作中碰到了使用$(this).attr("selected","selected")为option属性添加默认值时发现时而好用 时而不好用,后经百度发现 ...

  3. UVA 10900 So you want to be a 2n-aire? 2元富翁 (数学期望,贪心)

    题意:你一开始有1元钱,接下来又n<=30个问题,只需答对1个问题手上的钱就翻倍,最多答对n个,得到的钱是2n.而每个问题答对的概率是[t,1]之间平均分布,那么问最优情况下得到奖金的期望值是多 ...

  4. 在LXC Centos6-moban 编译安装mysql-5.6.36 时候遇见的报错

    在LXC安装Centos6-moban   编译安装mysql-5.6.36 cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 -DMY ...

  5. pickle 两个使用小方法

    def pickle_load(file_path): f = open(file_path,'r+') data = pickle.load(f) f.close() return data     ...

  6. stay hungry stay foolish.

    I am honored to be with you today at your commencement from one of the finest universities in the wo ...

  7. web中的$多种意思

    $符号在php中是表示变量的特征字符, 在js中它也有很多作用, 一般我们用来命名一个函数名称,获取id的1.首先可以用来表示变量, 比如变量 var s='asdsd'或var $s='asdasd ...

  8. POJ-1724 深搜剪枝

    这道题目如果数据很小的话.我们通过这个dfs就可以完成深搜: void dfs(int s) { if (s==N) { minLen=min(minLen,totalLen); return ; } ...

  9. 用户管理命令--useradd

    用户管理命令--useradd 作用:用于添加一个新的用户 格式:useradd [ 选项 ] 用户名 选项的常用介绍 -u: UID指定用户id,必须是唯一的,并且大于499 -c: 添加注释,可以 ...

  10. Memcached的安装和应用

    Memcached的安装 1.安装libeventlibevent是一个事件触发的网络库,适用于windows.linux.bsd等多种平台,内部使用 select.epoll.kqueue等系统调用 ...