最长递增子序列
#include#include #include #include using namespace std;#define maxn 40004int n;int f[maxn];int d[maxn];int m;void input(){ scanf("%d", &n); for (int i = 0; i < n ;i++) scanf("%d", &f[i]);}int binarysearch(int a){ int l = 0; int r = m; while (l < r) { int mid = (l + r) / 2; if (d[mid] < a) l = mid + 1; else r = mid; } if (l >= m) m++; return l;}int work(){ m = 0; for (int i = 0; i < n; i++) d[binarysearch(f[i])] = f[i]; return m;}int main(){ int t; scanf("%d", &t); while (t--) { input(); printf("%d\n", work()); } return 0;}