HDU 1087 Super jumping! jumping! jumping! Maximum Increment sub-sequence

Source: Internet
Author: User

Super jumping! jumping! jumping!

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 32564 Accepted Submission (s): 14692


Problem descriptionnowadays, a kind of chess game called "Super jumping! jumping! Jumping! "is very popular in HDU. Maybe you is a good boy, and know little about the this game, so I introduce it to you now.



The game can be played by and more than the players. It consists of a chessboard (chessboard) and some chessmen (chess pieces), and all chessmen is marked by a positive integer or "start" or "End ”. The player starts from start-point and must jumps to end-point finally. In the course of jumping, the player would visit the chessmen in the path, but everyone must jumps from one Chessman to Ano Ther absolutely bigger (you can assume start-point are 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 can straightly get to end-point From Start-point. Of course you get the 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 was described in a line as follow:
N value_1 value_2 ... value_n
It is guarantied, that N was not more than, and all value_i be in the range of 32-int.
A test case, starting with 0 terminates, the input and this test are not processed.

Outputfor, 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 OUTPUT4 10 3 Test instructions: To find the largest increment of the subsequence and without continuous, for example (1,5,2), then also counted his ascending subsequence. I just started to do it again, ignoring the problem of not using continuous, the results found good simple, submission is wrong, should pay attention to here. this still has to be done with dynamic planning, and the final best result is a previous decision with the result of the last step. n number, the result of the number of n-1 plus the nth number. N-1 number by n-2 number of results ..... The final two-digit result is easy to pull down. Take the series (3,2,4,2,3,6) as an example.   
Subscript I 0 1 2 3 4 5
A[i] 3 2 4 2 3 6
Sum[i] 3 2 7 2 5 13
Ans 0 3 7 7 5 13
  I think the dynamic planning idea of this topic must understand the two important codes. Another thing, Max () functions do not have to be defined separately, C + + can be directly called, no longer write the # define MAX (A, b) a>b? A:b this sentence. Code:
#include <iostream>#include<cstdio>//#define MAX (b) a>b? A:Busing namespacestd;intMain () {intN; inta[ +];//Store every number    intsum[ +];//The and of the incrementing subsequence before this number is stored    intAns//has been storing the largest and     while(SCANF ("%d", &n)!=eof && n!=0){         for(intj1=0; j1<n;j1++) {scanf ("%d",&a[j1]); } sum[0]=a[0]; Ans=0;  for(intI=1; i<n;i++) {ans=0;  for(intj=0; j<i;j++){                if(a[i]>A[j]) {ans=max (Sum[j],ans);//Important Code! }} Sum[i]=a[i]+ans;//Important Code! } ans=-1;  for(intI=0; i<n;i++){            if(ans<Sum[i]) {ans=Sum[i]; }} cout<<ans<<Endl; }    return 0;}
I am the code, please point me!!!

Do not understand the time, tell yourself, and then hold on, and then hold on, the question will be read.

Just start not to do, and then Baidu, saw a long time to see the method of the problem ~ ~ ~ (>_<) ~ ~ ~

HDU 1087 Super jumping! jumping! jumping! Maximum Increment sub-sequence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.