Cod sursa(job #1390647)

Utilizator Narcys01Ciovnicu Narcis Narcys01 Data 17 martie 2015 10:52:34
Problema Subsir crescator maximal Scor 35
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <iostream>
#include <fstream>
#define N 100005

using namespace std;

ifstream fin("scmax.in");
ofstream fout("scmax.out");

int a[N], b[N], p[N], n;

inline int Best(int i, int x)
{
    int bst = 0;
    for (i-- ; i > 0; i--)
        if (x > a[i] && b[i] > bst)
            bst = b[i];
    return bst;
}

int main()
{
    int i, bb = 0;
    fin >> n;
    for (i = 1; i <= n; i++)
        fin >> a[i];
    for (i = 1; i <= n; i++)
        b[i] = 1 + Best(i, a[i]);
    for (i = 1; i <= n; i++)
        if (bb < b[i])
            bb = b[i];
    fout << bb << "\n";
    return 0;
}