Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
代码备忘#include <iostream> using namespace std; double h[1100]; int dp[1100]; int cmax(int a,int b) { return a > b ? a : b; } int smax(int n) { int cmax = 0; for(int i = 1;i <= n;i++) if(cmax < dp[i]) cmax = dp[i]; return cmax; } int main() { int n,i,j; while(scanf("%d",&n) != EOF) { for(i = 0;i <= n ;i++) dp[i] = 1; for(i = 1;i <= n;i++) scanf("%lf",&h[i]); for(i = 2;i <= n;i++) for(j = i - 1;j > 0;j--) if(h[i] > h[j] && dp[i] <= dp[j]) dp[i] = cmax(dp[i],dp[j] + 1); cout << smax(n) <<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator