HDU 1087 Super Jumping! Jumping! Jumping!
来源:互联网 发布:管理学网络计划图例题 编辑:程序博客网 时间:2024/06/14 09:56
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.
![](https://odzkskevi.qnssl.com/b69a36fbfe92ef60e13d861294653386?v=1512186604)
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.
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.
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.
3 1 3 24 1 2 3 44 3 3 2 10
4103
题意:找一个最大的上升子序列求和并输出(简单dp)
#include<iostream>#include<cstdio>#include<cstring>#define maxn 1010#define INF 0x3f3f3f3fusing namespace std;int dp[maxn],n,a[maxn];int main(){ while(scanf("%d",&n)!=EOF&&n){ memset(dp,0,sizeof(dp)); for(int i=0;i<n;i++){ scanf("%d",&a[i]); dp[i]=a[i]; } for(int i=1;i<n;i++){ for(int j=0;j<i;j++){ if(a[i]>a[j]&&dp[i]<dp[j]+a[i]){ //判断上升子序列 其中// dp[i]<dp[j]+a[i]为判断子序列后一项大于前一项dp[i]=dp[j]+a[i]; } } } int MAX=-INF; for(int i=0;i<n;i++) if(MAX<dp[i]) MAX=dp[i]; printf("%d\n",MAX); } return 0;}
阅读全文
0 0
- hdu/hdoj 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- Hdu 1087 - Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- Hdu 1087 Super Jumping! Jumping! Jumping!
- hdu - 1087 - Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping! DP
- ACM训练半周总结—12月7日
- OpenAI探索机器人模拟训练新方法:仿真与真实世界无缝衔接
- use a circular buffer for video frames on iOS
- 深入理解Android音视频同步机制(二)ExoPlayer的avsync逻辑
- 58到家数据库30条军规解读
- HDU 1087 Super Jumping! Jumping! Jumping!
- 【操作系统】记录的成组误区
- 根文件系统中各个常用目录简介
- 理论知识:电路基础知识
- stm32f407部分外设驱动,can总线,定时器,gpio,串口,系统时钟等
- 最长公共子序列
- Java面试题:如何用java代码写一个堆栈
- 校招编程题:求最优解题方案
- 再探进程间通信