YT05-動態歸劃求解課後題目-1002—Super Jumping! Jumping! Jumping! -(6.21日-煙臺大學ACM預備隊解題報告)
Super Jumping! Jumping! Jumping!
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 19 Accepted Submission(s) : 6
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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 2 4 1 2 3 4 4 3 3 2 1 0
Sample Output
4 10 3
Author
lcy
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[1005],dp[1005];
const int inf = 999999999;
int main()
{
int n,i,t,m,j,ans;
while(scanf("%d",&n)&&n!=0)
{
memset(dp,0,sizeof(dp));
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;
}
相關文章
- YT05-動態歸劃求解課後題目-1004—Max Sum -(6.21日-煙臺大學ACM預備隊解題報告)ACM
- YT05-動態歸劃求解課堂題目-1003—數塔-(6.21日-煙臺大學ACM預備隊解題報告)ACM
- YT05-動態歸劃求解課後題目-1003—免費餡餅 -(6.21日-煙臺大學ACM預備隊解題報告)ACM
- 動態規劃入門G – Super Jumping! Jumping! Jumping! (有關最優子序列的一個相關題目)動態規劃
- YT05-動態歸劃求解課後題目-1001—FatMouse's Speed-(6.21日-煙臺大學ACM預備隊解題報告)ACM
- YT05-動態歸劃求解課堂題目-1004—最少攔截系統-(6.21日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課後題目-1002 超級樓梯-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課堂題目-1002 折線分割平面-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課後題目-1001 母牛的故事-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課堂題目-1001 蟠桃記-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課堂題目-1005 Children’s Queue-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- Jumping with Try
- Jumping with Option
- YT04-貪心課後練習-1002—Repair the Wall-(6.14日-煙臺大學ACM預備隊解題報告)AIACM
- YT03-遞推求解課堂題目-1004 不容易系列之一-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- YT03-遞推求解課後題目-1006 不容易系列之(4)——考新郎-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- Jumping in C++C++
- YT03-遞推求解課後題目-1003 不容易系列之(3)—— LELE的RPG難題-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- D. Fox And Jumping
- YT06-揹包-1002—Piggy-Bank -(6.27日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課後練習-1004—迷瘴-(6.14日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課後練習-1006—PAINTER(6.14日-煙臺大學ACM預備隊解題報告)AIACM
- YT03-遞推求解課堂題目-1003 獻給杭電五十週年校慶的禮物-(6.7日-煙臺大學ACM預備隊解題報告)ACM
- 題解:AT_abc257_d [ABC257D] Jumping Takahashi 2
- YT06-揹包-1001—Bone Collector -(6.27日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課堂練習-1004—Fire Net-(6.14日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課堂練習-1005—Wooden Sticks-(6.14日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課堂練習-1001 今年暑假不AC-(6.14日-煙臺大學ACM預備隊解題報告)ACM
- YT04-貪心課後練習-1003—悼念512汶川大地震遇難同胞——老人是真餓了-(6.14日-煙臺大學ACM預備隊解題報告)ACM
- YT06-揹包-1003—悼念512汶川大地震遇難同胞——珍惜現在,感恩生活 -(6.27日-煙臺大學ACM預備隊解題報告)ACM
- BZOJ(begin) 1328 [Usaco2003 Open]Jumping Cows:貪心【波峰波谷模型】模型
- 河南理工大學程式設計(ACM)大賽解題報告程式設計ACM
- 動態規劃求解最長上升子序列問題動態規劃
- 動態規劃解題方法動態規劃
- 動態規劃分類題目總結動態規劃
- 杭電ACM hdu 2079 選課時間 解題報告(母函式)ACM函式
- 大學畢業課題研究開題報告PPT分享-20套可下載
- NYNU ACM 藍橋杯選拔賽 解題報告ACM