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

LIS but wrong code???

Posted by mathsoft at 2006-07-24 19:38:51 on Problem 2533
#include<stdio.h>
#define N 1001
int length[N],data[N];
int LIS(int data[],int n)
{
    int i,j;
    for(i=0;i<=n;i++)length[i]=1;
	for(i=1;i<=n-1;i++)
		for(j=i+1;j<=n;j++)
			if(data[j]>data[i])
				if(length[i]+1>length[j])
					length[j]=length[i]+1;
	return length[n];
}
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		for(int i=1;i<=n;i++)
			scanf("%d",&data[i]);
		printf("%d\n",LIS(data,n));
		//for(i=0;i<=n;i++)printf("%d ",length[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