Kyopro Library
 
読み取り中…
検索中…
一致する文字列を見つけられません
lis.hpp
[詳解]
1#include"../../kyopro_library/template.hpp"
2
3/// @brief LIS
4/// @brief 配列 v の最長増加部分列の長さを返す
5/// @param strict `true` のとき狭義単調増加
6/// @note O(N log(N))
7int LisLength(vector<int>& v, bool strict=true) {
8 int n=v.size();
9 vector<int> dp(n,INF);
10 for(int i=0; i<n; i++) {
11 auto itr=(strict ? lower_bound(dp.begin(),dp.end(),v[i]) : upper_bound(dp.begin(),dp.end(),v[i]));
12 *itr=v[i];
13 }
14 return find(dp.begin(),dp.end(),INF)-dp.begin();
15}
int LisLength(vector< int > &v, bool strict=true)
LIS
Definition lis.hpp:7