当前位置:网站首页>Super Jumping! Jumping! Jumping!
Super Jumping! Jumping! Jumping!
2022-06-28 08:31:00 【Angeliaaa】
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( The board )and some chessmen( pieces ), 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
The question : Give me a number n, Represents the total number of pieces , After that n The number of pieces is the value of each piece , The latter is always bigger than the former , Find the maximum sum of pieces to walk .
Ideas : The question is dp thought , Use two layers for loop , find i The previous value is higher than i Small and num【j】 maximal , And then to num【i】=num【j】+a【i】, Then output the largest one . The code is as follows :
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long int a[1010],num[1010];
int main()
{
int n,i,j;
long long maxx,t;
while(~scanf("%d",&n)&&n)
{
maxx=-1;
memset(num,0,sizeof(num));
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
for(i=0;i<n;i++)
{
t=0;
for(j=i-1;j>=0;j--)
{
if(a[j]<a[i]&&t<num[j])
t=num[j];
}
num[i]=t+a[i];
maxx=max(maxx,num[i]);
}
printf("%lld\n",maxx);
}
return 0;
}
边栏推荐
- 【学习笔记】拟阵
- 开户券商怎么选择?网上开户是否安全么?
- Priority of JS operator
- Selenium+chromedriver cannot open Google browser page
- CloudCompare&PCL 点云裁剪(基于封闭曲面或多边形)
- 887. egg drop
- 找合适的PMP机构只需2步搞定,一查二问
- Solution: selenium common. exceptions. WebDriverException: Message: ‘chromedriver‘ execu
- On the solution of insufficient swap partition
- Anniversary party
猜你喜欢

关于在cmd中MySQL不能插中文数据的原因

B_ QuRT_ User_ Guide(27)

Kali Notes(1)

Wasmedge 0.10.0 release! New plug-in extension mechanism, socket API enhancement, llvm 14 support

AWS builds a virtual infrastructure including servers and networks (2)

What is the bandwidth of the Tiktok server that can be used by hundreds of millions of people at the same time?

WasmEdge 0.10.0 发布!全新的插件扩展机制、Socket API 增强、LLVM 14 支持
![Dell r730 server startup error: [xxx] USB 1-1-port4: disabled by hub (EMI?), re-enabling...](/img/90/425965ca4b3df3656ce2a5f4230c4b.jpg)
Dell r730 server startup error: [xxx] USB 1-1-port4: disabled by hub (EMI?), re-enabling...

ROS notes (09) - query and setting of parameters

找合适的PMP机构只需2步搞定,一查二问
随机推荐
AI chief architect 8-aica-gao Xiang, in-depth understanding and practice of propeller 2.0
Redis deployment under Linux & redis startup
Solve NPM err! Unexpected end of JSON input while parsing near
Force buckle 1884 Egg drop - two eggs
【力扣10天SQL入门】Day5+6 合并表
微内核Zephyr获众多厂家支持!
Quelle est la largeur de bande du serveur de bavardage sonore pour des centaines de millions de personnes en même temps?
探讨gis三维系统在矿山行业中的应用
B_ QuRT_ User_ Guide(26)
Login common test case
Oracle view all tablespaces in the current library
【学习笔记】差分约束
设置cmd的编码为utf-8
The maximum number of Rac open file descriptors, and the processing of hard check failure
TCP那点事
After installing NRM, the internal/validators js:124 throw new ERR_ INVALID_ ARG_ TYPE(name, ‘string‘, value)
Devops Basics: Jenkins deployment and use (I)
Priority of JS operator
Cloudcompare & PCL point cloud clipping (based on closed surfaces or polygons)
CloudCompare&PCL 点云裁剪(基于封闭曲面或多边形)