Cod sursa(job #3229400)

Utilizator FlaviuuuFlaviu Flaviuuu Data 15 mai 2024 20:48:02
Problema Subsir crescator maximal Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <fstream>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
#define fast ios:sync_with_stdio(false); cin.tie(0); cout.tie(0);
ifstream cin("scmax.in");
ofstream cout("scmax.out");
int main()
{
    ll n, l = 0;
    cin>>n;
    ll x;
    vector<ll> opt(1, -1e15);
    cin>>x;
    opt.push_back(x);
    for(ll i = 2; i <= n; i++)
    {
        cin>>x;
        if(x >= opt.back())
        {
            if(x>opt.back())opt.push_back(x);
            continue;
        }
        auto poz = lower_bound(opt.begin(), opt.end(), x);
        (*poz) = x;
    }
    cout<<opt.size() - 1<<'\n';
}