题目链接:点击打开链接、
题目大意:绕了这么多圈子,其实还是求最长上升子序列
题目分析:用nlog n
与 poj2533一样啊:点击打开链接
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
const int maxn=40005;
int stack[maxn];
int main()
{
freopen("out.txt","w",stdout);
freopen("in.txt","r",stdin);
int n,i,top,data,j,p;
scanf("%d",&n);
while(n--)
{
scanf("%d",&p);
top=0;stack[0]=-1;
for(i=0;i<p;i++)
{
scanf("%d",&data);
if(data>stack[top]) stack[++top]=data;
else
{
int l=1,r=top,mid;
while(l<=r)
{
mid=(l+r)/2;
if(data>stack[mid]) l=mid+1;
else r=mid-1;
}
stack[l]=data;
}
}
printf("%d\n",top);
}
}