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; int main() { int t,w; int dp[2][1001][31]; int d[1001],re; while(scanf("%d%d",&t,&w)!=EOF) { re=0; for(int i=0;i<t;i++) { scanf("%d",d+i); d[i]--; } dp[0][0][0]=(d[0]==0); dp[1][0][0]=(d[0]==1); for(int i=1;i<t;i++) { dp[0][i][0]=dp[0][i-1][0]+(d[i]==0); dp[1][i][0]=dp[1][i-1][0]+(d[i]==1); re=max(re,max(dp[0][i][0],dp[1][i][0])); } for(int i=1;i<t;i++) { for(int j=0;j<min(w,i);j++) { dp[1][i][j]=max(dp[1][i-1][j],dp[0][i-1][j-1])+(d[i]==1); dp[0][i][j]=max(dp[1][i-1][j-1],dp[0][i-1][j])+(d[i]==0); re=max(re,max(dp[0][i][j],dp[1][i][j])); } } printf("%d\n",re); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator