| ||||||||||
| 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<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int t,w,ans;
int dp[1200][50],a[1200];
int main()
{
scanf("%d%d",&t,&w);
for(int i=1;i<=t;i++)
{
scanf("%d",&a[i]);
}
for(int i=1;i<=t;i++)
{
dp[i][0]=dp[i-1][0]+(a[i]&1);
for(int j=1;j<=max(w,i);j++)
{
dp[i][j]=max(dp[i-1][j],dp[i-1][j-1])+(1&(a[i]^j));
}
}
for(int i=0;i<=w;i++)
ans=max(ans,dp[t][i]);
printf("%d",ans);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator