Pagini recente » Cod sursa (job #3136779) | Cod sursa (job #3201675) | Cod sursa (job #3141925) | Cod sursa (job #2493235) | Cod sursa (job #3128927)
#include <bits/stdc++.h>
using namespace std;
const string FNAME = "scmax.";
ifstream fin(FNAME + "in");
ofstream fout(FNAME + "out");
int main() {
int n;
fin >> n;
int x;
fin >> x;
vector<int> dp = {x};
for (int i = 1; i < n; i++) {
fin >> x;
auto it = lower_bound(dp.begin(), dp.end(), x);
if (it == dp.end()) {
dp.push_back(x);
} else {
*it = x;
}
}
fout << dp.size() << '\n';
for (int it : dp) {
fout << it << ' ';
}
fout << endl;
fout.close();
return 0;
}