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. windows 查看某端口被占用情况

    百度经验 http://jingyan.baidu.com/article/3c48dd34491d47e10be358b8.html 基本命令 netstat -ano

  2. Linux 使用常见问题

    1. 如何查看软件安装到什么位置 [Ubuntu] 今天安装了Lxc-docker,想看一下文件都安装到哪里了,首先找到这个包的ersion zhouh1@uhome:~$ dpkg -s lxc-d ...

  3. QTableWidget表头样式

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7742680.html QTableView { background-color: rgba(255, 255 ...

  4. 第一周作业javaee strainmap

  5. WPF知识点全攻略00- 目录

    知识点目录如下: 1.WPF相对WinFrom的优缺点 2.WPF体系结构 3.XAML 4.XAML页面布局 5.XAML内容控件 6.WPF中的“树” 7.Binding 8.依赖属性 9.附加属 ...

  6. Win10本地搭建Apache+PHP运行环境

    微软全新操作系统Windows10在190个国家和地区正式同步上市,正版Windows7.Windows8.1用户均可在一年内免费升级.介绍一下在升级后的Windwos10系统上安装及配置Apache ...

  7. Gradle dependencies 依赖方式

    implementation:使用了该命令编译的依赖,仅仅对当前的Moudle提供接口 依赖首先应该设置为implement的,如果没有错,那就用implement,如果有错,那么使用api指令 那为 ...

  8. faster rcnn环境编译

    步骤和fast rcnn的编译一样,在编译中遇到了一个问题: 刚开始是以为python-numpy没有安装到位,后来发现是Makefile.config的配置出现了问题.原来的配置是: PYTHON_ ...

  9. 手动编译openslide

    1.下载openslide源代码, 2.转到openslide代码目录: ./configure 3.安装依赖库: sudo apt-get update sudo apt-get install l ...

  10. Visual C++中error spawning cl.exe错误的两种解决方法.

    可能很多人在安装VC 6.0后有过点击“Compile”或者“Build”后被出现的 “Compiling... ,Error spawning cl.exe”错误提示给郁闷过.很多人的 选择是重装, ...