1 #include<time.h>
2 #include <cstdio>
3 #include <iostream>
4 #include<algorithm>
5 #include<math.h>
6 #include <string.h>
7 #include<vector>
8 #include<queue>
9 using namespace std;
10
11 int d[100005],a[100005];
12 int len,i,k,n,m;
13
14 int binary(int t)
15 {
16 int low,high,mid;
17 low=0;
18 high=len;
19 while(low<high)
20 {
//mid=low+(high-low)*(num-p[low])/(p[high]-p[low]);//插值排序
21 mid=(low+high)/2;
22 if(d[mid]<=t)
23 low=mid+1;
24 else
25 high=mid;
26 }
27 return low;
28 }
29
30 int main()
31 {
32 int cas;
33 cin>>cas;
34 while(cas--)
35 {
36 cin>>n;
37 for(i=1;i<=n;i++)
38 cin>>a[i];
39 len=0;
40 d[0]=-99999;
41 for(i=1;i<=n;i++)
42 {
43 if(a[i]>d[len])
44 {
45 len++;
46 d[len]=a[i];
47 //cout<<d[len]<<" ";
48 }
49 else
50 {
51 k=binary(a[i]);
52 d[k]=a[i];
53 }
54 }
55 cout<<len<<endl;
56 if(cas) //这里是个坑
57 cout<<endl;
58 }
59 return 0;
60 }