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)