| ||||||||||
| 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 | |||||||||
简单小dp,贴小代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator