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

WA好几次,才发现不是变换次数最多的拿的apple多

Posted by 1654995440 at 2014-08-06 14:00:53 on Problem 2385
#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:
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