Summer Camp (5) First play ——— Super jumping! jumping! jumping! (hdu1087)

Source: Internet
Author: User

Test instructions: In the last three games with the Suo Satan, you all won. He made a request to the Satan and, with his power, sent it to a safe place.

Your wishes have been reached, but you and little a seem to be separated.

The streets are bustling with people, and everyone's face is filled with happiness. " Cuckoo ... "Well, dig out your pocket, except you.

"I heard that, Tak Yuen Street where there is a mental game, said the winner can go to" eat full "restaurant to eat full, and the top three will also have mysterious prizes ..."

This time, in order to fill ... Well, in order to survive, you decide to take part in this tournament, and the match asks you to get the maximum sequential ascending sequence and in the given number.

Problem analysis: To obtain is the maximal increment sub-sequence and, with the recursive method, first I need reverse order, first calculate the back, then gradually recursion.

Equation is hit dp[i] = max (dp[i],m[i]+dp[j]);

1#include"Cstdio"2 intm[ +];3 intdp[ +];4 voidMbegin (intN)5 {6      for(intI=0; i<n;i++)7     {8scanf ("%d",&m[i]);9Dp[i] =M[i];Ten     } One } A intMaxintXinty) - { -     returnX>y?x:y; the } - intMain () - { -     intN; + __int64 sum; -      while(SCANF ("%d", &n) &&N) +     { A mbegin (n); at          for(inti=n-1; i>=0; i--) -           for(intj=i;j<n;j++) -          { -             if(M[i] <M[j]) -Dp[i] = max (dp[i],m[i]+dp[j]); -          } insum = dp[0]; -          for(intI=0; i<n;i++) to         { +            if(Sum <Dp[i]) -sum =Dp[i]; the         } *printf ("%i64d\n", sum); $     }Panax Notoginseng  -     return 0; the}
View Code

Summer Camp (5) First play ——— Super jumping! jumping! jumping! (hdu1087)

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.