Pagini recente » Cod sursa (job #960248) | Cod sursa (job #682156) | Cod sursa (job #186615) | Cod sursa (job #3001609) | Cod sursa (job #2457699)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("scmax.in");
ofstream out("scmax.out");
int v[100000], l[100000], pred[100000], maxi, a, pmax, lc, n;
void subsir(int p)
{
if(pred[p] != 0){
subsir(pred[p]);
}
out << v[p] << " ";
}
int main()
{
in >> n;
for(int i = 0; i < n; i++){
in >> v[i];
lc = 0;
for(int j = 0; j < i; j++){
if(v[j] < v[i]){
if(l[j] > lc){
lc = l[j];
pred[i] = j;
}
}
}
l[i] = 1 + lc;
if(l[i] > l[pmax]){
pmax = i;
}
}
out << l[pmax] << "\n";
subsir(pmax);
return 0;
}