Cod sursa(job #2335335)
| Utilizator | Data | 3 februarie 2019 22:12:24 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 55 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <bits/stdc++.h>
int main() {
std::ifstream fin("scmax.in");
std::ofstream fout("scmax.out");
std::vector<int> lis;
int n;
fin >> n;
while(n--) {
int x;
fin >> x;
auto it = std::upper_bound(lis.begin(), lis.end(), x);
if(it == lis.end()) lis.push_back(x);
else *it = x;
}
lis.erase(std::unique(lis.begin(), lis.end()), lis.end());
fout << lis.size() << '\n';
for(auto i: lis) fout << i << ' ';
}
