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

简单小dp,贴小代码

Posted by WilliamACM at 2012-05-02 11:51:48 on Problem 2385
#include <iostream>
#include <stdio.h>
using namespace std;
int a[31][2]={0};
int main()
{
    int i,j,n,w;
    scanf("%d%d",&n,&w);
    for(i=1;i<=n;i++)
    {
        int come;
        scanf("%d",&come);come--;
        for(j=w-1;j>=0;j--) 
        a[j][come]=max(a[j][come]+1,a[j+1][(come+1)%2]+1);
        a[w][come]++;
    }
    printf("%d\n",max(a[0][0],a[0][1]));
    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