Cod sursa(job #2966441)

Utilizator SkaduweePavel Bogdan Stefan Skaduwee Data 17 ianuarie 2023 17:14:29
Problema Subsir crescator maximal Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <fstream>
#include <vector>
using namespace std;

const int NMAX = 100000;
int n, v[NMAX+1], s[NMAX+1];
vector <int> sol;
int main()
{
    ifstream fin("scmax.in");
    ofstream fout("scmax.out");

    fin >> n;
    fin >> v[0];
    s[0] = 2;
    s[1] = v[0];
    for (int i = 1; i < n; i++){
        fin >> v[i];
        int j = s[0];
        for (; j > 1; j--)
            if (s[j-1] < v[i]){
                s[0] = max (s[0], j+1);
                s[j] = v[i];
                break;
            }

        if (s[j] > v[i])
        {
            s[j] = v[i];
        }
    }

    fout << s[0] - 1;
    return 0;
}