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

N肯定有大于80000的 我把int改成unsigned int 就从wa 变成ac 大家注意了

Posted by Bzin at 2008-11-19 18:29:05 on Problem 3250 and last updated at 2008-11-19 18:29:52
int的最大值肯定够用 80000*80000=1.6*10^9
我用二分做的

unsigned int Do(int left,int right)
{
	int max;
	int i,j;
	int center;
	unsigned int retur;
	if(left==right)
		return 0;
	center=(left+right)/2;
	retur = Do(left,center)+Do(center+1,right);

	j=center+1;
	max=0;
	for(i=center;i>=left;i--)
	{
		if(Hight[i]>max)
		{
			max=Hight[i];
			for(;j<=right;j++)
			{
				if(Hight[j]>=max)
					break;
			}
			retur += j-center-1;
		}
	}
	return retur;
}

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