!!流弊的方法
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 0x3f3f3f3f;
const int M = 100011;
int n;
int a[M];
vector<int>v;
inline void gao(int now)
{
if (v.empty() || now >= v[v.size() - 1])
{
v.push_back(now);
}
else
{
v[upper_bound(v.begin(), v.end(), now) - v.begin()] = now; //二分查找替换
}
}
int main()
{
int T;
cin >> T;
while (T--)
{
cin >> n;
for (int i = 1; i <= n; i++)
{
//cin >> a[i];
scanf("%d",&a[i]);
}
v.clear();
int now;
for (int i = n; i >= 1; i--)
{
now = a[i]*2+1 ; //避免重复
gao(now);
}
for (int i = 1; i <= n; i++)
{
now = a[i]*2;
gao(now);
}
// for(int i=0; i<v.size(); ++i)
// {
// cout<<v[i]<<" ";
//
// }
//
// puts("");
cout << v.size() << endl;
}
return 0;
}