HDU 1087 Super Jumping! Jumping! Jumping!【dp】
来源:互联网 发布:快速排序算法c语言实现 编辑:程序博客网 时间:2024/04/24 14:29
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35625 Accepted Submission(s): 16206
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
转移方程:sum[j]=max{sum[i]}+a[j];
#include<cstdio>#include<cmath>#include<cstring>#include<climits>#include<string>#include<queue>#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<climits>#include<string>#include<queue>#include<stack>#include<set>#include<map>#include<algorithm>using namespace std;#define rep(i,j,k)for(i=j;i<k;i++)#define per(i,j,k)for(i=j;i>k;i--)#define MS(x,y)memset(x,y,sizeof(x))#define max(a,b) a>b?a:b#define min(a,b) a<b?a:b#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef long long LL;const int INF=0x7ffffff;#define lson rt<<1, l, m#define rson rt<<1|1, m+1, rconst int M=1e3+1;int dp[M],a[M];int i,j,k,n,m;int ans;int main(){ while(~scanf("%d",&n),n){ MS(dp,0); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=n;i++){ ans=-INF; for(j=0;j<i;j++){ if(a[i]>a[j])ans=max(ans,dp[j]); } dp[i]=ans+a[i]; } ans=-INF; for(i=0;i<=n;i++){ if(dp[i]>ans){ ans=dp[i]; } } printf("%d\n",ans); } return 0;}
0 0
- hdu 1087 Super Jumping! Jumping! Jumping! DP
- HDU 1087 Super Jumping! Jumping! Jumping! DP
- hdu 1087 Super Jumping! Jumping! Jumping! ----dp
- HDU 1087 Super Jumping! Jumping! Jumping!(dp)
- Super Jumping! Jumping! Jumping! -HDU 1087 dp
- HDU 1087 Super Jumping! Jumping! Jumping!(DP)
- HDU 1087 Super Jumping! Jumping! Jumping! DP
- HDU 1087 Super Jumping! Jumping! Jumping!(DP)
- HDU 1087 Super Jumping! Jumping! Jumping!(DP)
- [HDU 1087 Super Jumping! Jumping! Jumping!] DP
- DP-HDU-1087-Super Jumping!Jumping!Jumping!
- HDU-1087-DP-Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!(DP)
- hdu 1087 Super Jumping! Jumping! Jumping! dp
- HDU 1087 Super Jumping! Jumping! Jumping! DP
- HDU 1087 Super Jumping! Jumping! Jumping!【dp】
- HDU-1087 Super Jumping! Jumping! Jumping! (DP)
- HDU-1087 Super Jumping! Jumping! Jumping!(DP)
- [容斥 状压DP 树形DP] BZOJ 4455 [Zjoi2016]小星星 & UOJ #185 【ZJOI2016】小星星
- springMVC实现ajax功能返回json
- RTEMS针对MPC8313开发板的移植
- unity3d开发 打飞机小游戏(五)(飞机移动/敌机死亡动画)
- sqlserver数据库merge操作
- HDU 1087 Super Jumping! Jumping! Jumping!【dp】
- 陈省身文集40——21世纪的数学
- node npm包管理器
- strcpy,一道有趣的面试题
- MongoDB WiredTiger 存储引擎(1) cache_pool设计
- VR系列——Oculus Publishing文档:三、内容标准和要求
- 监听接收到的短信
- 异常Hibernate:could not initialize proxy - no Session
- java.lang.IllegalStateException: Driver for test database type [H2] is not available in the classpat