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

逻辑有问题,如果前面没有数比它小,长度应该为1 ,看我ac的

Posted by yao503 at 2007-12-20 16:53:29 on Problem 2533
In Reply To:How could this be wrong? 555 Posted by:yogafrank at 2007-11-30 20:08:01
#include "stdio.h"

int main(void)
{
	int n,a[1001],c[1001];
	int i,j,temp,max;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	c[1]=1;
	for(i=2;i<=n;i++)
	{
		max=1;
		for(j=i-1;j>=1;j--)
		{
			if (max>j+1) {
				break;
			}
			if (a[i]>a[j]) {
				temp=c[j]+1;
				if (temp>max) {max=temp;
				}
			}
		}
		c[i]=max;
	}
	max=1;
	for(i=1;i<=n;i++)
	{
		if (c[i]>max) {max=c[i];
		}
	}
	printf("%d",max);
}

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