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

O(nlogn)复杂度63ms 1A,贴过程

Posted by 1403mashaonan at 2015-02-21 20:46:24 on Problem 3903
int a[MAX];
int main(){
	int L,x;
	while(~scanf("%d",&L)){
		int top=0;
		a[0]=0;
		for(int i=0;i<L;i++){
			scanf("%d",&x);
			if(x>a[top]) a[++top]=x;
			else{
				int low=0,high=top;
				while(low<=high){
					int mid=(low+high)/2;
					if(a[mid]>=x) high=mid-1;
					else low=mid+1;
				}
				a[low]=x;
			}
		}
		printf("%d\n",top);
	}
	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