题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1950
题目很简单,就是要用nlogn时间复杂度求解该题。
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define INF 0x3f3f3f3f
int dp[40002],a[40002];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
fill(dp,dp+n,INF);
for(int i=0;i<n;i++)
*lower_bound(dp,dp+n,a[i])=a[i];
cout<<lower_bound(dp,dp+n,INF)-dp<<endl;
}
return 0;
}