Cod sursa(job #2233080)

Utilizator sidorencuoanaSidorencu Oana Alexandra sidorencuoana Data 22 august 2018 10:00:59
Problema Subsir crescator maximal Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#define MAX 100000

using namespace std;

ifstream f("csmax.in");
ofstream g("csmax.out");

int N;
long int a[MAX],l[MAX];

void SECMAX (int N,long int a[MAX])
{
    int i,k,max,max2=0;
    l[N]=1;
    for(i=N-1;i>=1;i--)
    {
        max=0;
        for(k=i+1;k<=N;k++)
           if(a[k]>a[i] && l[k]>max)
           max=l[k];
        l[i]=1+max;
        g<<l[i];
        if(l[i]>max2)
        max2=l[i];
    }
    g<<max2<<endl;
}

int main()
{int i;
f>>N;
g<<N;
for(i=1;i<=N;i++)
f>>a[i];
for(i=1;i<=N;i++)
g<<a[i];

SECMAX(N,a);

    return 0;
}