Cod sursa(job #904172)

Utilizator Anamaria20Cotirlea Anamaria Anamaria20 Data 3 martie 2013 20:31:56
Problema Subsir crescator maximal Scor 35
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include <stdio.h>

FILE *f,*s;

int n,i,j,k,max;

int v1[100005],v2[100005],v3[100005];

int main()
{
	f=fopen("scmax.in","r");
	s=fopen("scmax.out","w");
	
	fscanf(f,"%d",&n);
	
	for(i=1;i<=n;i++)
		fscanf(f,"%d",&v1[i]);
	
	for(i=1;i<=n;i++)
	{
		v2[i]=1;
		v3[i]=-1;
		
		for(j=1;j<=i-1;j++)
		{
			if(v1[j]<v1[i] && v2[j]+1>v2[i])
			{
				v2[i]=v2[j]+1;
				v3[i]=j;
			}
		}
		
		if(v2[max]<v2[i])
			max=i;
	}
	
	fprintf(s,"%d",v2[max]);
	
	fclose(s);
	
	return 0;
}