Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

真的那么难么

Posted by liu_cheng_ao at 2016-09-19 11:40:44 on Problem 2385
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator