• + 1 comment
    //O(nlogn)
    // 
    #include <string>
    #include <cstring>
    #include <iostream>
    #include <iomanip>
    #include <vector>
    #include <algorithm>
    #include <sstream>
    #include <map>
    #include <set>
    #include <cmath>
    #include <fstream>
    #include <queue>
    using namespace std;
    using ll=long long;
    
    //F[i] save the last element min it can obtain of increasing subsequence its length = i 
    //dung bs
    //lowerbound phan tu dau tien >=a[i]
    //in: 9
    //1 4 2 3 8 10 6 9 13
    //out:6
    //ket qua:1 2 3 6 9 13
    
    
    
    
    
    
    
    
    int main()
    { 
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        
        int n;cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
    
        vector<int> res;
        res.push_back(a[0]);
        for(int i=1;i<n;i++)
        {
            auto it =lower_bound(res.begin(),res.end(),a[i]);
            if(it==res.end())
                res.push_back(a[i]);
            else
                *it=a[i];
            // for(int x:res)
            //     cout<<x<<' ';
            // cout<<endl;
        }
        //cout<<endl;
        cout<<res.size();
    }
    
    • + 0 comments

      When it comes to Longest Increasing Subsequence (LIS) in carpet cleaning, think of it as uncovering the "hidden order" in deep-cleaning strategies for consistently impressive results. Just as the LIS algorithm identifies the longest subsequence of numbers in ascending order, effective carpet cleaning requires a sequence of steps, each building on the last to enhance cleanliness without redundancy. Starting with dry vacuuming, we lay a clean foundation, removing loose debris to avoid clogging the cleaning solutions. Next, pre-treating tough stains before the main wash ensures that we address the most embedded dirt, making it easier for deep-clean extraction to follow. Finally, each rinse and drying step solidifies this sequence, leaving a fresher, thoroughly cleaned carpet. By following a structured approach, we achieve not just clean but sustained cleanliness—much like finding that perfect sequence to optimize the outcome!