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 |
求大牛指点迷津啊!!dp为何始终wa啊!!!#include<stdio.h> #include<string.h> int a[200000]; int dp[400000]; int main() { int n; while(~scanf("%d",&n)) { if(n<=0) break; memset(dp,0,n+3); for(int j=0;j<n;j++) { scanf("%d",&a[j]); } dp[0]=1; int i,j; for( j=1;j<n;j++) { if(a[j]>a[j-1]) dp[j]=dp[j-1]+1; else if(a[j]==a[j-1]) dp[j]=dp[j-1]; else { for(i=0;i<j;i++) { if(a[j]==a[i]) { dp[j]=dp[i]; break; } if(a[j]>a[i]&&a[j]<a[i+1]) { dp[j]=dp[i]+1; break; } } if(i==j) dp[j]=1; } } int m=-454545; for( i=0;i<n;i++) { if(m<dp[i]) m=dp[i]; } printf("%d\n",m); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator