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<stdio.h> #include<string.h> #define MAX 1005 int dp[MAX], a[MAX]; int main() { int n, i, j; while (~scanf("%d",&n)) { for (i=0;i<n;i++) scanf("%d",&a[i]); memset(dp,0,sizeof(dp)); int max = 0; for (i=0;i<n;i++) { for (j=i+1;j<n;j++) { if (a[j] > a[i]) { dp[j] = dp[j]>(dp[i]+1) ? dp[j] : (dp[i]+1); } if (dp[j] > max) max = dp[j]; // printf("%d\n",dp[j]); } } printf("%d\n",max+1); } return 0; } 这样求最长上升子序列可以吗?为什么有的时候WA了。。。如果不正确,跪求测试啊 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator