【 HDU 1087】 Super Jumping! Jumping! Jumping! 动态规划

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 53239    Accepted Submission(s): 24682


 

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.

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.

 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

题意:就是给你一个n,然后给你n个数,让你选择一个上升子序列的最大和。

题解:这道题的模型还是LIS问题,只不过我们存储状态dp[i]表示以i结尾的不下降子序列的最大和,预处理的时候,每一个以自身结尾的不下降子序列的最大和就是自己。

#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1000+7;
int a[maxn],dp[maxn];
int n,ans;
int max(int x,int y)
{
    return x>y?x:y;
}
int LIS()
{
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]<a[j]){
                dp[j]=max(dp[j],dp[i]+a[j]);
            }
        }
    }
    int mx=-1;
    for(int i=1;i<=n;i++)
    mx=max(mx,dp[i]);
    return mx;
}
int main()
{
    while(scanf("%d",&n)==1&&n){
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            dp[i]=a[i];
        }
        printf("%d\n",LIS());
    }
    return 0;
}

 

Super Jumping! Jumping! Jumping! (上升子序列的最大和) 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 ... 阅读详情

相关推荐

Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 36493    Accepted Submission(s): 16643 Problem Description Nowadays, a kind of chess gam

qq_36392612的博客 430

Super Jumping! Jumping! Jumping! (非连续递增序列求和)

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 ...

薄荷糖 1417

杭电oj1087Super Jumping! Jumping! Jumping!动态规划入门)

Super Jumping! Jumping! Jumping! 题目链接 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) 动态规划的入门试题,我竟然wa了三次,唉。 代码: #include<iostream> #include<algorithm> ...

醉酒诗人的博客 415

hdoj1087 Super Jumping! Jumping! Jumping!(DP)

题意:  并不是从start一步一步地走、一直走到end然后取最大值这么简单,而是在某一点上可以一次性走N步到达另一个店,比如这里“1”可以直接走到“2”(不过一定是从左到右,不能回头),不过这样的结果只是3了,不是最大值。所以,这是一个DP问题。状态转移方程先写出来,等下再分析:// origin[]为原数组,dp[]是在origin[]上进行动态规划的数组 // dp[i]表示“走到下标为i的这

VitaLemon__的专栏 863

hdu1087 : Super Jumping! Jumping! Jumping!(动态规划)

http://acm.hdu.edu.cn/showproblem.php?pid=1087 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...

273

HDU 1087 Super Jumping! Jumping! Jumping! -- 简单动态规划

/* http://acm.hdu.edu.cn/showproblem.php?pid=1087 HDU 1087 Super Jumping! Jumping! Jumping! 状态转移方程为:sum[i] = { max(sum[j] + num[i]) , 1 <= j < i } ; */ #include #include #include #incl

生命有一种绝对 668

hdu1087 Super Jumping! Jumping! Jumping!(简单动态规划

就要回宿舍了!; 好吧,俺就水一道了~! 大神请尽管指责,俺脸皮厚! #include #include int main() { int n,a[2000],i,s[2000],j; while(scanf("%d",&n),n) { memset(s,0,sizeof(s)); for(i=0;i scanf("%d",&a[i]); s[0]=a[0]; fo

YAN 599

hdu 1087 Super Jumping! Jumping! Jumping! 动态规划

Super Jumping! Jumping! Jumping! Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Problem Description Nowadays, a kind of chess game called “Super Jumping! Jum

LYHVOYAGE的专栏 1085

HDU-P1087:Super Jumping! Jumping! Jumping![动态规划]

HDU-P1087:Super Jumping! Jumping! Jumping![动态规划] 题目 题目链接 思路 又是英文题面,不过思路还是很清晰的,题目要求找一条单调递增的序列,使得经过路径的数字和最大,只需要将求解最长递增序列的代码稍作修改即可。 代码 #include <iostream> #include <cstdio> #include <algorithm> using namespace std; int solve(int a[], int N)

ZhuTT的博客 203

hdu 1087 Super Jumping! Jumping! Jumping!动态规划DP)

hdu 1087 Super Jumping! Jumping! Jumping!动态规划DP) 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 6553...

weixin_30826095的博客 129

HDU 1087 Super Jumping! Jumping! Jumping! 动态规划

题目大意: 从起点开始到终点,

Gatevin的专栏 627

动态规划训练17 [Super Jumping! Jumping! Jumping! HDU - 1087 ]

Super Jumping! Jumping! Jumping!  HDU - 1087  过于简单懒得说了 #include #include #include using namespace std; const int MAX = 1000; int a[MAX]; int dp[MAX]; main(){ int N; while(scanf("%d",&

SUNSET 207

hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 47017 Accepted Submission(s): 21736 Problem Description...

devon2014的博客 109

HDU 1087Super Jumping! Jumping! Jumping! (dp动态规划)

点击打开题目 Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 40346    Accepted Submission(s): 18614

Manton's blog 297

HDU1087 - Super Jumping! Jumping! Jumping!动态规划

zh成功的在他人的帮助下获得了与小姐姐约会的机会,同时也不用担心被非“川大”的女票发现了,可是如何选择和哪些小姐姐约会呢?zh希望自己可以循序渐进,同时希望挑战自己的极限,我们假定每个小姐姐有一个“攻略难度值” 从攻略成功第一个小姐姐开始,zh希望每下一个需要攻略的小姐姐难度更高,同时又希望攻略难度值之和最大,好了,现在小姐姐们排成一排,zh只能从左往右开始攻略,请你帮助他找到最大的攻略难度和 ...

独钓门前月 413

hdu 1087 Super Jumping! Jumping! Jumping!(dp)

hdu 1087 Super Jumping! Jumping! Jumping! http://acm.hdu.edu.cn/showproblem.php?pid=1087 ProblemDescription Nowadays,akindofchessgamecalled“SuperJumping!Jumping!Jumping!”isv...

diansitao5461的博客 90

E - Super Jumping! Jumping! Jumping! HDU 1087 (基础动态规划

E - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1087 Description Nowadays, a kind of chess game called “Super

qwesde 734

hdu 1087 Super Jumping! Jumping! Jumping! 动态规划

题意:求n个点的和最大上升子序列。 简单题,d[i]=max(d[j]+a[i]),(j #include #include #include #define N 1100 using namespace std; int d[N],a[N]; int main() { int n; while(scanf("%d",&n)&&n) { for(i

弱菜zc 793
上一篇: 【 POJ 1088】 滑雪 动态规划
下一篇: 【HDU 2044】 一只小蜜蜂 递推
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值