const LL N = ;
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 >= )
{
if (r - l <= )
return go(l, r, k);
LL mid = (l + r) >> ;
if (dp[mid] > k)
r = mid;
else
l = mid;
}
}
LL solve(LL n)
{
fill(dp, dp + N, N + );
dp[] = ;
LL ans = ;
for (int i = ; i < n; i++)
{
LL e = num[i];
LL ads = bins(, i, e);
dp[ads + ] = min(dp[ads + ], e);
ans = max(ans, ads+);
}
//cout << ans << endl;
return ans;
}
相关文章
- 最长上升子序列 nlogn
- 力扣1143. 最长公共子序列
- Atcoder F - LCS (DP-最长公共子序列,输出字符串)
- HDU 1025 Constructing Roads In JGShining's Kingdom(求最长上升子序列nlogn算法)
- POJ 1159 Palindrome(区间DP/最长公共子序列+滚动数组)
- [LeetCode]516. 最长回文子序列[记忆化搜索解法详解]
- 每日OJ题_子序列dp①_力扣300. 最长递增子序列
- poj 3903 最长上升子序列 Stock Exchange
- 【算法框架套路】最长公共子序列
- CSP-动态规划-最长公共子序列(LCS)-二、动态规划的例子