其他分享
首页 > 其他分享> > Super Jumping! Jumping! Jumping!超级跳!跳!跳!

Super Jumping! Jumping! Jumping!超级跳!跳!跳!

作者:互联网

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.
现在,一种叫做“超级跳跃”的国际象棋游戏!跳!跳!“在HDU很受欢迎。也许你是个好孩子,对这个游戏知之甚少,所以我现在给你介绍一下。
这个游戏可以由两个或两个以上的人玩。它由一个棋盘(棋盘)和一些棋子(棋子)组成,所有棋子都被正整数或“开始”或“结束”标记。玩家从起点开始,最后必须跳入终点.在跳跃的过程中,玩家会拜访路径上的棋手,但是每个人都必须从一个棋子跳到另一个更大的棋子(你可以假设起点是最小的,终点是最大的)。所有球员都不能倒退。一次跳跃可以从一个棋子跳到下一个,也可以穿过许多棋子,甚至你也可以从起点直接到达终点。当然,在这种情况下你会得到零点。一个球员是胜利者,只要他能根据他的跳跃解决方案得到更大的分数。注意,你的分数来自于你跳跃路径中棋手的价值之和。
您的任务是根据给定的棋子列表输出最大值。
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.
输入
输入包含多个测试用例。每个测试用例用一行描述如下:nn值_1值_2…值n_nit保证N不超过1000,并且所有的值_i都在32-int的范围内。从0开始的NA测试用例终止输入,此测试用例将不被处理。
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
思路:得分来自跳转路径中的棋子是的值的和,根据给定棋子列表输出最大值

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int a[1000010],b[1000010],s;
	while(scanf("%d",&n)&&n!=0){
		memset(b,0,sizeof(b));//b数组是递增序列的最大和 
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]);
		int k=-30000;//最小值,可能是负数 
		for(int i=1;i<=n;i++){
			s=-30000;//初始最小值 
			for(int j=0;j<i;j++)
				if(a[j]<a[i]&&s<b[j])
					s=b[j];
				b[i]=s+a[i];//最大递增序列和 
				if(b[i]>k)
				k=b[i];
		}
		printf("%d\n",k);
	}
	return 0;
} 

标签:point,int,超级,value,chessmen,Jumping,棋子,Super
来源: https://blog.csdn.net/weixin_45987032/article/details/104851176