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 suhang at 2010-01-24 12:29:41 on Problem 2189 and last updated at 2010-01-24 12:29:52
#include <cstdio>

const int maxn=1100;
int a[maxn],sum[maxn],n,p,c,x;

int main()
{
	freopen("p2189.in","r",stdin);
	freopen("p2189.out","w",stdout);
	
	scanf("%d%d%d",&n,&p,&c);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x!=p)
		a[x+1]++;
		else
		a[p]++;
	}
	sum[0]=0;
	p++;
	a[p]=0;
	for (int i=1;i<=p;i++)
	sum[i]=sum[i-1]+a[i];
	int max=0;
	for (int i=1;i<p;i++)
	for (int j=i;j<p;j++)
	if (sum[j+1]-sum[i-1]<=c && j-i+1>max)
	max=j-i+1;
	printf("%d\n",max);
	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