Cod sursa(job #2591087)
Utilizator | Dumitrescu Gheorghe k2e0e0w3q | Data | 29 martie 2020 18:43:45 |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 65 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 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> v;
int n, x;
for (fin >> n; n; n--) {
fin >> x;
auto it = upper_bound(v.begin(), v.end(), x-1);
if (it==v.end())
v.push_back(x);
else
*it=x;
}
fout << v.size() << '\n';
for (auto it: v)
fout << it << ' ';
return 0;
}