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啊,大牛门帮看看啊T_T``另外时间越界是什么意思啊?

Posted by cangratul at 2007-02-05 09:08:20 on Problem 3104
#include <stdio.h>
void main()
{
	int a[100000],i,n,k,mid,sum,min,max;
	while((scanf("%d",&n))!=EOF)
	{
		min=0;
		max=1;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]>max) max=a[i];
		}
		scanf("%d",&k);
		if(k!=1)
		{
			while(min<=max)
			{
				sum=0;
				mid=(max+min)>>1;
				for(i=0;i<n;i++)
				{
					if(a[i]>mid)
					{
						sum+=(a[i]-mid-1)/(k-1)+1;
					}
				}
				if(sum>mid) min=mid+1;
				else max=mid-1;
			}
			max++;
		}
		printf("%d\n",max);
	}
}

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