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

Re:不要随便乱说!

Posted by Bzin at 2008-11-20 18:40:07 on Problem 3250
In Reply To:Re:不要随便乱说! Posted by:ABD at 2008-11-19 20:38:48
Source Code

Problem: 3250  User: Bzin 
Memory: N/A  Time: N/A 
Language: C++  Result: Wrong Answer 

Source Code 
#include <stdio.h>
#include <string.h>

const int Size=80002;

int N;
int Hight[Size];

void Read()
{
	int i;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		scanf("%d",&Hight[i]);
}

int Do(int left,int right)
{
	int max;
	int i,j;
	int center;
	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;
}

int Work()
{
	if(N==1)
		return 0;
	return Do(1,N);
}


int main()
{
//	freopen("in.txt","r",stdin);
	int result;
	Read();
	result=Work();
	printf("%d\n",result);
	return 0;
}


Source Code

Problem: 3250  User: Bzin 
Memory: 516K  Time: 141MS 
Language: C++  Result: Accepted 

Source Code 
#include <stdio.h>
#include <string.h>

const int Size=80002;

int N;
int Hight[Size];

void Read()
{
	int i;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		scanf("%d",&Hight[i]);
}

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;
}

unsigned int Work()
{
	if(N==1)
		return 0;
	return Do(1,N);
}


int main()
{
//	freopen("in.txt","r",stdin);
	unsigned int result;
	Read();
	result=Work();
	printf("%u\n",result);
	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