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 |
无奈,苦恼这道题,感觉可能错误的地方都想到了,为什么还会WA呢? #include <stdio.h> void main() { int count,num[10000],dp[10000],max,n,i,j,judge=0,cal=0; while(judge!=-1) { i=1; count=0; cal++; scanf("%d",&n); while(n!=-1) { num[i]=n; i++; judge=1; count++; scanf("%d",&n); } if(n==-1) judge-=1; dp[1]=1; for(i=2;i<=count;i++) { max=1; j=1; while(j<=i-1) { if(num[i]<=num[j]) if(dp[j]+1>max) max=dp[j]+1; j++; } dp[i]=max; } if(judge!=-1) { printf("Test #%d:\n",cal); printf(" maximum possible interceptions: %d\n\n",dp[count]); } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator