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

Why WA?????

Posted by BJ051155 at 2007-07-10 20:23:34 on Problem 3250
#include <stdio.h>
unsigned long h[80001],num[80001];
int id[80001];

int main(int argc, char* argv[])
{
	int n;
	unsigned long total=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	id[n]=0;
	for(i=n-1;i>=1;i--)
	{
		int j=i+1;
		while(j&&h[j]<h[i])
		{
			num[i]+=1;
			num[i]+=num[j];
			j=id[j];
		}
		id[i]=j;
		total+=num[i];
	}
	printf("%d\n",total);
	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