Cod sursa(job #640800)

Utilizator alexdmotocMotoc Alexandru alexdmotoc Data 26 noiembrie 2011 15:26:44
Problema Subsir crescator maximal Scor 5
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include <iostream>
#include <cstdio>

using namespace std;

#define maxN 100005

long long x[maxN];
int N , maxx , maxim , best[maxN];

int main ()
{
	freopen ("scmax.in" , "r" , stdin);
	freopen ("scmax.out" , "w" , stdout);
	
	scanf ("%d" , &N);
	
	for (int i = 1 ; i <= N ; ++i)
	{
		scanf ("%lld" , &x[i]);
		
		if (x[i] > x[i - 1] && best[i - 1] + 1 > maxim)
		{
			maxim = best[i - 1] + 1;
			best[i] = maxim;
		}
		
		else 
		{
			maxx = 0;
			
			for (int j = i - 1 ; j >= 1 ; --j)
				if (best[j] > maxx)
					maxx = best[j];
				
			best[i] = maxx;
		}
	}
	
	printf ("%d" , maxim);
	
	return 0;
}