Cod sursa(job #2489859)
Utilizator | Data | 9 noiembrie 2019 12:20:37 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 55 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("scmax.in");
ofstream g("scmax.out");
int n,x,nr,i,l[100005],poz;
int main()
{
f>>n;
f>>x;
l[1]=x;
nr=1;
for(i=2; i<=n; i++)
{
f>>x;
poz=upper_bound(l+1,l+nr+1,x)-l;
l[poz]=x;
if(poz>nr)
nr=poz;
}
g<<nr<<'\n';
for(i=1;i<=nr;i++)
g<<l[i]<<' ';
g<<'\n';
return 0;
}