Cod sursa(job #2722467)
Utilizator | Data | 12 martie 2021 21:07:36 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 65 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define mF "scmax"
std::ifstream in(mF ".in");
std::ofstream out(mF ".out");
#include <vector>
#include <algorithm>
int main()
{
std::vector<int> V; int n; in >> n; while (n--)
{int e; in >> e; auto i = std::lower_bound(V.begin(), V.end(), e); if (i == V.end()) V.push_back(e); else *i = e;}
out << V.size() << '\n'; for (int e: V) out << e << ' ';
}