Cod sursa(job #2553679)

Utilizator Chirac_MateiChiriac Matei Chirac_Matei Data 22 februarie 2020 11:02:05
Problema Subsir crescator maximal Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
ifstream fin ("scmax.in");
ofstream fout ("scmax.out");
vector <int> best;
int n,x,i,poz;
int main()
{
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>x;
        if(i==1 || x>best[best.size()-1])
            best.push_back(x);
        else
        {
            poz = lower_bound(best.begin(), best.end(), x) - best.begin();
            best[poz]=x;
        }
    }
    fout<<best.size();
    return 0;
}