Cod sursa(job #643157)

Utilizator d.andreiDiaconeasa Andrei d.andrei Data 3 decembrie 2011 01:39:06
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <cstdio>

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

#define nmax 5010

int N,T;
int i,max,j;
int x[nmax];
int y[nmax];
int z[nmax];
int best[nmax];

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[i], &y[i], &z[i]);
		
		max=0;
		best[N]=1;
		for (i=N-1;i>=1;--i){
			best[i]=1;
			for (j=i+1;j<=N;++j)
				 if (best[i]<best[j]+1 && x[i]<=x[j] && y[i]<=y[j] && z[i]<=z[j])
					  best[i]=best[j]+1;
			          if (best[i]>max) max=best[i];	 
		}
		printf("%d\n", max);
		
	}
	
	return 0;
}