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好几次,才发现不是变换次数最多的拿的apple多#include <iostream> #include<cstdio> #include<algorithm> #include<string.h> using namespace std; int t,w,a[10005],dp[55][2]; int main() { while(scanf("%d%d",&t,&w)!=EOF) { int p=0,m=0; memset(dp,0,sizeof(dp)); for(int i=0;i<t;i++) { scanf("%d",&a[i]); a[i]--; for(int j=0;j<=p;j++) { dp[j][a[i]]++; if(dp[j][a[i]]>m) m=dp[j][a[i]]; if(dp[j+1][a[i]]<dp[j][!a[i]]) { dp[j+1][a[i]]=dp[j][!a[i]]; if(j==p&&p<w) p++; } } } printf("%d\n",m); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator