Cod sursa(job #2590920)

Utilizator k2e0e0w3qDumitrescu Gheorghe k2e0e0w3q Data 29 martie 2020 12:35:13
Problema Subsir crescator maximal Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
using namespace std;

int main () {
    ifstream fin ("scmax.in");
    ofstream fout ("scmax.out");
    ios::sync_with_stdio(false);

    vector <int> deck;
    int n, x;
    for (fin >> n; n; n--) {
        fin >> x;
        auto it = upper_bound(deck.begin(), deck.end(), x-1);
        if (it==deck.end())
            deck.push_back(x);
        else
            deck[it-deck.begin()]=x;
    }
    fout << deck.size();
    return 0;
}