Cod sursa(job #3345371)

Utilizator ScipexRobert Chiri Scipex Data 9 martie 2026 13:32:02
Problema Subsir crescator maximal Scor 65
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("scmax.in");
ofstream fout("scmax.out");

int main() {
    int n, x;
    vector<int> scm;

    fin >> n;
    for (int i = 0; i < n; i++) {
        fin >> x;

        auto it = lower_bound(scm.begin(), scm.end(), x);
        if (it == scm.end()) {
            scm.push_back(x);
        } else {
            *it = x;
        }
    }

    fout << scm.size() << "\n";
    for (auto& e : scm) {
        fout << e << " ";
    }
}