晕晕的无解
nlgn的算法,但是为什么会WA了呢!!!
最长不降啊
怎么会WA啊!求解
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[100001],c[100001],len;
int find(int l,int r,int x)
{
	if(l==r) return l;
	int mid=(l+r)>>1;
	if (c[mid]<x) return find(mid+1,r,x);
	else return find(l,mid,x);
}
int main()
{
	int n;
	while(scanf("%lld",&n)!=EOF)
	{
		for (int i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			c[i]=0;
		}
		//memset(c,0,sizeof(c));
		c[0]=-1;
		len=0;
		for (int i=0;i<n;i++)
		{
			if (a[i]>c[len]) c[++len]=a[i];
			else 
			{
				c[find(1,len,a[i])]=a[i];
				len=find(1,len,a[i]);
			}
		}
		printf("%lld\n",len);
	}
	return 0;
}
© 2015 HUST ACMICPC TEAM. All Right Reserved.