Cod sursa(job #2518316)
| Utilizator | Data | 5 ianuarie 2020 15:10:54 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 55 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
//#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int Max=100005;
ifstream in("scmax.in");
ofstream out("scmax.out");
vector <int>v; int n;
int main()
{
in>>n;
for(int i=1;i<=n;i++)
{
int x; in>>x;
int poz=upper_bound(v.begin(),v.end(),x)-v.begin();
if(poz==v.size() && (poz==0 || v[poz-1]!=x))
v.push_back(x);
else
v[poz]=x;
}
out<<v.size()<<"\n";
for(int j=0;j<v.size();j++)
out<<v[j]<<" ";
return 0;
}
