Cod sursa(job #365303)

Utilizator AndreiDDiaconeasa Andrei AndreiD Data 18 noiembrie 2009 13:21:21
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <cstdio>
#include <cstring>

#define file_in "cutii.in"
#define file_out "cutii.out"

int N,T,i,j,best[10000],x,y,z,v[10100],cmax;

int main()
{
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	scanf("%d %d", &N, &T);
	
	while(T--)
	{
		for (i=1;i<=N;++i)
		{
			scanf("%d %d %d", &x, &y, &z);
			
			v[i]=x*y*z;
		}
		
		cmax=0;
		
		memset(best,0,sizeof(best));
		
		best[N]=1;
		
		for (i=N-1;i>=1;--i)
		{
			best[i]=1;
			
			for (j=i+1;j<=N;++j)
				if (v[i]<v[j] && best[i]<best[j]+1)
					best[i]=best[j]+1;
			if (best[i]>cmax)
                cmax=best[i];
        }
		
		printf("%d\n", cmax);
	}
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
	
}