| ||||||||||
| 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<stdio.h>
int max( int a,int b)
{
if(a>b)
return a;
else return b;
}
int main(){
int a[1001][2]={0},i,j,k,i1;
long b[100]={0},count;
int t,w;
scanf("%d%d",&t,&w);
i1=1;
scanf("%d",&a[i1][1]);
a[i1][0]=1;
for(i=2;i<=t;i++)
{
scanf("%d",&k);
if(a[i1][1]==k)
{
a[i1][0]++;
}else
{
i1++;
a[i1][1]=k;
a[i1][0]=1;
}
}
for(i=1;i<=i1;i++)
{
if(i<=w)
k=i;
else
k=w;
for(j=0;j<=k;j++)
{
if(a[i][1]==2&&j%2==1)
{
b[j]=max(b[j],b[j-1])+a[i][0];
}else if(a[i][1]==1&&j%2==0)
{
b[j]=max(b[j],b[j-1])+a[i][0];
}
}
}
count=0;
for(j=0;j<=w;j++)
{
if(b[j]>count)
count=b[j];
}
printf("%d",count);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator