HDU 1087 Super Jumping! Jumping! Jumping!
来源:互联网 发布:淘宝宝贝描述上传图片 编辑:程序博客网 时间:2024/06/03 17:06
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23230 Accepted Submission(s): 10227
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
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
using namespace std;
//dp[i]=max(dp[i],dp[j]+a[i]); (1<=j<i) dp[i]表示以a[i](第i个数)为结尾能得到的最大上升子序列
//当且仅当a[i]>a[j]&&dp[i](1<j<i)<dp[j]+a[i]时能进行dp[i]=dp[j]+a[i]的更新
int a[1001],dp[1001];
int n,ans;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d",&n),n)
{
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
cle(dp);
ans=-1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<i;j++)
if(a[i]>a[j])
{
dp[i]=max(dp[i],dp[j]+a[i]);
}
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
}
return 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
- CF 258B. Sort the Array
- CF 261A. Pashmak and Garden
- stl-algorithm用法
- HDU 1505City Game
- 【问题解决】FragmentTabHost 底部菜单栏,切换Frgment时重新加载问题
- HDU 1087 Super Jumping! Jumping! Jumping!
- POJ 2533 LIS N2
- 【转载】继承(C#)
- HDU 1166 敌兵布阵
- HOJ 1876经理的烦恼
- HDU 2097Sky数
- HDU 2046骨牌铺方格(滚动数组)
- POJ 2352 Stars
- HDU-5053 the Sum of Cube