首页 技术 正文
技术 2022年11月12日
0 收藏 542 点赞 4,626 浏览 1761 个字

Super Jumping! Jumping! Jumping!

Problem DescriptionNowadays, 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.

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

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. InputInput 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. OutputFor each case, print the maximum according to rules, and one line one case. Sample Input3 1 3 24 1 2 3 44 3 3 2 10 Sample Output4103 题目大意:求出序列从左到右,满足下一个数比上一个数大的条件,的最大序列和。 代码如下:

 # include <iostream>
# include<cstdio>
# define LL long long
using namespace std; int main()
{
int n,ans,max,i,j;
int s[],a[]; //s[i]表示最末尾是a[i]这个数的结果
bool flag;
while(scanf("%d",&n)&& n)
{
for(i=; i<n; i++)
{
scanf("%d",&a[i]);
s[i] = ;
}
s[] = a[];
for(i=; i<n; i++)
{
s[i] = a[i];
for(j=; j<i; j++)
{
if(a[i]>a[j] && s[j]+a[i]>s[i])
{
s[i] = s[j] + a[i];
}
}
}
max = ;
for(i=;i<n;i++)
{
if(s[i]>max)
max = s[i];
}
printf("%d\n",max);
}
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295