cp_library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub downerkei/cp_library

:heavy_check_mark: dp/longest_increasing_subsequence.hpp

Verified with

Code

template<class T>
int longest_increasing_subsequence(const vector<T> &A) {
    vector<T> lis;
    for(const auto& p : A) {
        // 狭義
        auto it = lower_bound(lis.begin(), lis.end(), p);
        if(lis.end() == it) lis.push_back(p);
        else *it = p;
    }
    return lis.size();
}
#line 1 "dp/longest_increasing_subsequence.hpp"
template<class T>
int longest_increasing_subsequence(const vector<T> &A) {
    vector<T> lis;
    for(const auto& p : A) {
        // 狭義
        auto it = lower_bound(lis.begin(), lis.end(), p);
        if(lis.end() == it) lis.push_back(p);
        else *it = p;
    }
    return lis.size();
}
Back to top page