Cod sursa(job #2518333)

Utilizator tavi255Varzaru Octavian Stefan tavi255 Data 5 ianuarie 2020 15:37:41
Problema Subsir crescator maximal Scor 65
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 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;
        if(binary_search(v.begin(),v.end(),x)==0)
        {
                int poz=upper_bound(v.begin(),v.end(),x)-v.begin();
               if(poz==v.size())
                  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;
}