Cod sursa(job #744761)

Utilizator dragos94Bobaru Dragos dragos94 Data 9 mai 2012 16:45:01
Problema Subsir crescator maximal Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include <cstdio>

using namespace std;

int

int cautare(int x,int st,int dr)
{
    int m;
    poz=0;
    while(st<=dr && poz=0){
    m=(st+dr)/2;
    if (q[m]==x) poz=m;
    else if (q[m]>x) dr=m-1;
    else st=m+1;}
    if(poz==0) poz=st;
    q[poz]=x;
    return poz;
    }
void scrie(int i,int x,int max)
{
    if (i>0)
    {
     if(a[i]<x && p[i]==max) scrie(i-1,a[i],max-1);
     printf("%d ",a[i]);
    }
    else scrie(i-1,x,max);
}

int main()
{
    freopen("scmax.in","r",stdin);
    freopen("scmax.out","w",stdout);
    scanf("%d",&n);max=0;l=0;
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++){p[i]=cautare(a[i],1,l);if(p[i]>max) max=p[i];poz2=i;}
    printf("%d",l);