This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub mugen1337/procon
#include "DP/LongestIncreasingSubsequence.hpp"
最長増加列の長さを返す.
配列の長さをNとすると O(NlogN)
template<typename T> int LongestIncreasingSubsequence(vector<T> v,bool strict=true){ vector<T> lis; for(auto &x:v){ typename vector<T>::iterator ite; if(strict) ite=lower_bound(begin(lis),end(lis),x); else ite=upper_bound(begin(lis),end(lis),x); if(ite==end(lis)) lis.push_back(x); else *ite=x; } return int(lis.size()); }
#line 1 "DP/LongestIncreasingSubsequence.hpp" template<typename T> int LongestIncreasingSubsequence(vector<T> v,bool strict=true){ vector<T> lis; for(auto &x:v){ typename vector<T>::iterator ite; if(strict) ite=lower_bound(begin(lis),end(lis),x); else ite=upper_bound(begin(lis),end(lis),x); if(ite==end(lis)) lis.push_back(x); else *ite=x; } return int(lis.size()); }