标签:format bottom process ane sel eve tar inner other
Description
Input
Output
Sample Input
Sample Output
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int a[1010],f[1010]; int main() { int n; while(~scanf("%d",&n)) { if(!n) break; memset(a,0,sizeof(a)); for(int i=0;i<n;i++) scanf("%d",&a[i]); int maxn = 0; for(int i=0;i<n;i++) { f[i] = a[i];//先给每个f[i]附一个本身的值 for(int j=i-1;j>=0;j--) { if(a[i]>a[j]&&a[i]+f[j]>f[i])//从a[i]的前面找出比a[i]小的 f[i] = a[i] + f[j];//然后dp每个f[i] }//注意 4 3 2 1 3 结果为5 递增序列为 2 3 } for(int j=n-1;j>=0;j--) { if(maxn < f[j]) maxn = f[j]; } printf("%d\n",maxn); } return 0; }
HDU 1087 Super Jumping! Jumping! Jumping!
标签:format bottom process ane sel eve tar inner other
原文地址:http://www.cnblogs.com/l609929321/p/6718279.html