#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll maxn=1e9+10; int N[100010]; int ans[100010]; int b[100010]; int ind[100010]; int Search(int num, int low, int high) { int mid; while(low<=high) { mid=(low+high)/2; if(num>b[mid]) low=mid+1; else high=mid-1; } return low; } int DP( int n) { int i,len,pos; b[1]=N[1]; ind[1]=1; len=1; for(i=2; i<=n; i++) { if(N[i]>b[len]) { len++; ind[i]=len; b[len]=N[i]; } else { pos=Search(N[i],1,len); ind[i]=pos; b[pos]=N[i]; } } return len; } int main() { int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); for (int i=1; i<=n; i++) scanf("%d",&N[i]); DP(n); ans[1]=1; for (int i=1;i