This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
/*
知识点内容:最长上升子序列2
文档内容参考:
https://www.cnblogs.com/aiguona/p/7278141.html
*/
#define MAXN 40005
using namespace std;
int arr[MAXN], ans[MAXN], len;
int main() {
int n;
int T;
cin >> T;
while (T--) {
cin >> n;
for (int i = 1; i <= n; ++i)
scanf("%d", &arr[i]);
ans[1] = arr[1];
len = 1;
for (int i = 2; i <= n; ++i) {
if (arr[i] > ans[len])
ans[++len] = arr[i];
else {
int pos = lower_bound(ans, ans + len, arr[i]) - ans;
ans[pos] = arr[i];
}
cout << len << endl;
return 0;