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

那你试试这题http://acm.hnu.cn:8080/online/?action=problem&type=show&id=10027

Posted by yiyiyi4321 at 2005-12-16 13:52:28 on Problem 2533
In Reply To:规模为1000,n^2的算法就可以过了,不用二分的 Posted by:xinz at 2005-12-16 13:16:21
改了,还是错的
#include<stdio.h>
long a[1001],d[1001];
main()
{long i,n,len=0;
 long mid,left,right;
 scanf("%ld",&n);
 for(i=0;i<n;i++)
  {scanf("%ld",&a[i]);
   d[i]=0;
  }
 for(i=0;i<n;i++)
  {
   if(a[i]>d[len])
     d[++len]=a[i];
   else
   {
	 left=1;
	 right=len;
	  while(left<=right)
	 {
	  mid=(left+right)/2;
	  if(d[mid-1]<a[i]&&d[mid]>=a[i])break;
	  if(a[i]>d[mid])
	    left=mid+1;
	  if(a[i]<d[mid])
	    right=mid-1;
	 }
	 if(left<=right)d[mid]=a[i];
   }
  }
  printf("%ld",len);
 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