hdoj--1087--Super Jumping! Jumping! Jumping!(最长上升序列)
来源:互联网 发布:编程足球循环赛 编辑:程序博客网 时间:2024/05/16 08:21
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30884 Accepted Submission(s): 13833
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.
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.
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 24 1 2 3 44 3 3 2 10
Sample Output
4103
Author
lcy
Recommend
We have carefully selected several similar problems for you: 1159 1069 1058 1171 1160
呵呵,刚开始我竟然在dfs,,,,,,
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#define ll long long#define N 1010#define M 1000000007using namespace std;ll dp[N];ll a[N];int main(){int t,n,m;int i,j,k;while(scanf("%d",&n),n){memset(dp,0,sizeof(dp));for(i=0;i<n;i++)scanf("%d",&a[i]),dp[i]=a[i];dp[0]=a[0];ll maxx=-1;for(i=0;i<n;i++){for(j=0;j<i;j++){if(a[j]<a[i])dp[i]=max(dp[i],dp[j]+a[i]);}maxx=max(maxx,dp[i]);}printf("%lld\n",maxx);}return 0;}
0 0
- hdoj--1087--Super Jumping! Jumping! Jumping!(最长上升序列)
- HDU 1087 Super Jumping! Jumping! Jumping!最长上升子序列
- hdu 1087 Super Jumping! Jumping! Jumping!(最长上升子序列变形)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
- HDU 1087 Super Jumping! Jumping! Jumping! (最长上升子序列和)
- HDU 1087 Super Jumping! Jumping! Jumping!(dp最长上升子序列的和)
- HDU1087 Super Jumping! Jumping! Jumping!【最长上升子序列+DP】
- HDU 1087 Super Jumping! Jumping! Jumping! (最长上升子序列求和)【最长序列求和类模板】
- 【最长上升子序列】HDU 1087——Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!-dp 最长上升子序列和
- hdu 1087 Super Jumping! Jumping! Jumping!(最长上升子序列&dp)
- hdu 1087 Super Jumping! Jumping! Jumping! 最长上升子序列的变形
- HDU 1087 Super Jumping! Jumping! Jumping!【最长上升子序列元素总和】
- Super Jumping! Jumping! Jumping! 【hdu-1087】【动态规划-最长上升子序列】
- Super Jumping! Jumping! Jumping! (最长上升子序列的和)
- hdu1087 Super Jumping! Jumping! Jumping!(最长上升子序列和)
- HDU 1087 Super Jumping! Jumping! Jumping!(最大的上升子序列的和)(不是最长)(易混淆)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp+最长递增序列)
- lintcode:Construct Binary Tree from Preorder and Inorder Traversal
- utf-8与utf-8无BOM的区别
- java队列、栈和多线程结合使用的例子
- framebuffer 测试程序 arm linux 6410 2440 2416
- 抽象类与接口有什么区别
- hdoj--1087--Super Jumping! Jumping! Jumping!(最长上升序列)
- Android.Camera2相机超详细讲解
- 传纸条
- 数组array和vector的比较
- ionicView的生命周期
- 数据库 'DB 的事务日志已满。若要查明无法重用日志中的空间的原因,请参阅 sys.d
- js 局部变量和全局变量
- windows7 64位无法安装dnw的驱动解决方案
- HTML5存储—LocalStorage 和 sessionStroage