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了n遍

Posted by kiki620 at 2014-01-09 01:19:22 on Problem 2559 and last updated at 2014-01-09 01:23:45
终于a了。
看开网上的题解和源码也不靠谱啊。还得字节写。
在数列的最后加上一个0,保证最后出栈能够top==0;
如果当前高度>栈顶高度,压栈。
否则出栈:
else
			{
				flag=0;
				while(top>=0 && z[top].h>a[i])
				{
					flag=1;
					tot=(i-1-z[top].id+1)*z[top].h;
					if(tot>ans)
						ans=tot;
					top--;
				}
				top++;
				z[top].h=a[i];
				if(flag==0)
					z[top].id=i;
			}

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