Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1087
Test instructions is to give you the number of N, find out a sequence of the largest and, this sequence to meet the rules of increasing in turn;
Ah, this problem has been done before, but a little impression is not but their own writing out, it is estimated that at that time did not know why write it, it turns out that the problem is more natural to understand;
I did it with the idea of ascending the subsequence.
#include <stdio.h>#include<string.h>#include<algorithm>using namespacestd;#defineN 1100#defineINF 0XFFFFFFFintMain () {intN, A[n], dp[n], Max; while(SCANF ("%d", &N) {memset (A,0,sizeof(a)); Memset (DP,0,sizeof(DP)); for(intI=1; i<=n; i++) {scanf ("%d", &A[i]); } Max=0; for(intI=1; i<=n; i++) {Dp[i]=A[i]; for(intj=1; j<=i; J + +) { if(a[i]>A[j]) dp[i]= Max (Dp[i], dp[j]+A[i]); } Max=Max (max, dp[i]); } printf ("%d\n", Max); } return 0;}View Code
Super jumping! jumping! Jumping!---hdu1087 (Dynamic planning)