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?

Posted by jiangfan87 at 2009-08-08 11:24:02 on Problem 1887
#include<stdio.h>
#include<string.h>

int maxn[6000],data[6000];

int main()
{
	int n=0,t=0,i,j,d;
	memset(maxn,0,sizeof(maxn));
	memset(data,0,sizeof(data));
	while(1)
	{
		scanf("%d",&d);
		if(d==-1)
		{
			t++;
			maxn[1]=1;
			for(i=2;i<=n;i++)
				for(j=1;j<i;j++)
				{
					if(data[j]>data[i])
						maxn[i]=(maxn[j]+1<maxn[i]?maxn[i]:maxn[j]+1);
					else
						maxn[i]=(maxn[i]<1?1:maxn[i]);
				}
			int mm=0;
			for(i=1;i<=n;i++)
				if(mm<maxn[i])
					mm=maxn[i];
			printf("Test #%d:\n  maximum possible interceptions: %d\n\n",t,mm);
			scanf("%d",&d);
			if(d==-1)
				break;
			memset(maxn,0,sizeof(maxn));
			memset(data,0,sizeof(data));
			n=0;
		}
		else
		{
			n++;
			data[n]=d;
		}
	}
	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