当前位置:网站首页>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;
}
边栏推荐
- The maximum number of Rac open file descriptors, and the processing of hard check failure
- AWS saves data on the cloud (3)
- 40多岁的人如何配置年金险?哪款产品比较合适?
- Quelle est la largeur de bande du serveur de bavardage sonore pour des centaines de millions de personnes en même temps?
- Wasmedge 0.10.0 release! New plug-in extension mechanism, socket API enhancement, llvm 14 support
- 【Go ~ 0到1 】 第一天 6月24 变量,条件判断 循环语句
- 开户券商怎么选择?网上开户是否安全么?
- [learning notes] differential constraint
- 为什么函数模板没有偏特化?
- Why MySQL cannot insert Chinese data in CMD
猜你喜欢

About using font icons in placeholder

Devops foundation chapter Jenkins deployment (II)

Introduction to Devops Basics

B_QuRT_User_Guide(27)

设置网页的标题部分的图标

Quelle est la largeur de bande du serveur de bavardage sonore pour des centaines de millions de personnes en même temps?

Children's unit of 2022 Paris fashion week ended successfully at Wuhan station on June 19

ROS notes (08) - definition and use of service data

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

Image translation /transformer:ittr: unpaired image to image translation with transformers
随机推荐
[learning notes] linear basis
解决npm ERR! Unexpected end of JSON input while parsing near问题
设置cmd的编码为utf-8
redis02——一篇终结redis的五种数据类型操作命令(可学习、复习、面试、收藏备用)
App automated testing appium Tutorial Part 1 - advanced supplementary content
Anniversary party
CloudCompare&PCL 点云裁剪(基于封闭曲面或多边形)
Login common test case
广州:金融新活水 文企新机遇
Kubernetes notes and the latest k3s installation introduction
【学习笔记】搜索
Case tool
PMP从报考到拿证基本操作,了解PMP必看篇
Trailing Zeroes (II)
抖音服务器带宽有多大,才能供上亿人同时刷?
Wasmedge 0.10.0 release! New plug-in extension mechanism, socket API enhancement, llvm 14 support
CloudCompare&PCL 点云SVD分解
Build an integrated kubernetes in Fedora
Doris学习笔记之介绍、编译安装与部署
B_QuRT_User_Guide(29)