Cod sursa(job #1168655)

Utilizator stefi123ristea stefan stefi123 Data 9 aprilie 2014 10:45:41
Problema Subsir crescator maximal Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include "stdafx.h"
#include "fstream"
#include <stdio.h>

using namespace std;


long long vector[100000];
int best[100000];
int a[100000];
long long sol[100000];
int main()
{
    ifstream f("scmax.in");
	ofstream g("scmax.out");
	//while(!f.eof())
	//{
		int i,n,ind,max,maxbest,indmax,j;
		f>>n;
		for(i=1;i<=n;i++)
			f>>vector[i];
		best[1]=1;
		maxbest=1;
		a[0]=-1;
		ind=1;
		for(i=2;i<=n;i++)
		{
			max=0;
			for(j=i-1;j>=1;j--)
				if(vector[i]>vector[j]&&best[j]>max)
				{
					max=best[j];
					ind=j;
				}
			best[i]=max+1;
			a[i]=ind;
			if(vector[i]<=vector[ind])
			{
				best[i]=1;
				a[i]=-1;
			}
			if(maxbest<best[i])
			{
				maxbest=best[i];
				indmax=i;
			}
		}

		g<<maxbest;
	//}
    return 0;
}