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

这样子为什么过不了??

Posted by 20110706 at 2011-12-13 01:52:30 on Problem 2181
#include<stdio.h>
const int max=150005;
int potion[max],mark[max];
int main()
{
	int p,max=0;
	scanf("%d",&p);
	for(int i=0;i<p;i++)
	{
		scanf("%d",&potion[i]);
		mark[i]=0;
	}
	if(potion[0]>potion[1])
		mark[0]=1;
	if(potion[p-1]>potion[p-2])
		mark[p-1]=1;
	for(int i=1;i<p-1;i++)
	{
		if(potion[i]>potion[i-1]&&potion[i]>potion[i+1])
			mark[i]=1;
		if(potion[i]<potion[i-1]&&potion[i]<potion[i+1])
			mark[i]=-1;
	}
	for(int i=0;i<p;i++)
			max+=mark[i]*potion[i];
	printf("%d\n",max);
}





输入的potion有没有可能相同的啊?

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