Cod sursa(job #1366545)

Utilizator witselWitsel Andrei witsel Data 1 martie 2015 11:01:59
Problema Subsir crescator maximal Scor 35
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=100001;
int n,a[nmax],best[nmax];
void citire()
{
    ifstream fin("scmax.in");
    fin>>n;
    for(int i=1;i<=n;++i)
        fin>>a[i];
}
void subsir2()
{
    ofstream fout("scmax.out");
    int bmax=0;
    for(int i=1;i<=n;++i)
        best[i]=1;
    for(int i=n-1;i>=1;--i)
        for(int j=i+1;j<=n;++j)
            if(a[i]<a[j] && best[i]<=best[j])
                best[i]=best[j]+1 ;
    for(int i=1;i<=n;++i)
        if(bmax<best[i])
        bmax=best[i];
    fout<<bmax;

}
int main()
{
    citire();
    subsir2();
    return 0;
}