最长上升子序列 nlogn
const LL N = 100005; LL num[N]; LL dp[N]; LL go(LL l, LL r, LL k) { for (; r >= l; r--) if (dp[r] <= k) return r; return l; } LL bins(LL l, LL r, LL k) { while (r - l >= 0) { if (r - l <= 5) return go(l, r, k); LL mid = (l + r) >> 1; if (dp[mid] > k) r = mid; else l = mid; } } LL solve(LL n) { fill(dp, dp + N, N + 1); dp[0] = 0; LL ans = 0; for (int i = 0; i < n; i++) { LL e = num[i]; LL ads = bins(0, i, e); dp[ads + 1] = min(dp[ads + 1], e); ans = max(ans, ads+1); } //cout << ans << endl; return ans; }