Pagini recente » Cod sursa (job #1205090) | Cod sursa (job #1268244) | Cod sursa (job #3259075) | Cod sursa (job #553717) | Cod sursa (job #2591087)
#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;
}