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

求数据啊,为什么一直是wrong answer?

Posted by 20110706 at 2011-12-13 09:54:44 on Problem 2181
#include<stdio.h>
const int maxp=150005;
int potion[maxp],mark[maxp];
int main()
{
	int p,maxj=0,step=0,k=0;
	scanf("%d",&p);
	for(int i=0;i<p;i++)
	{
		scanf("%d",&potion[i]);
		mark[i]=0;
	}
	while(k<p)
	{
		if(step%2==0)
		{
			while(potion[k]<=potion[k+1])
				k++;
			mark[k]=1;
			step++;
		}
		else
		{
			while(potion[k]>=potion[k+1])
			k++;
			mark[k]=-1;
			step++;
		}
	}
	for(int i=p-1;i>=0;i--)
		if(mark[i]==1)
			break;
		else
			if(mark[i]==-1)
			{
				mark[i]=0;
				break;
			}
			for(int i=0;i<p;i++)
				maxj+=potion[i]*mark[i];
			printf("%d\n",maxj);
}

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