Cod sursa(job #595260)

Utilizator veleanduAlex Velea veleandu Data 11 iunie 2011 18:48:15
Problema Cutii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include<fstream>
using namespace std;
typedef struct { long x,y,z; } punct;
long i,j,n,t,l,maxim;
long REZ[3505];
punct T[3505];
bool myfct ( punct a, punct b)
{
	if ( a.x < b.x )
		return 1;
	return 0;
}
int main()
{
	ifstream in("cutii.in");
	ofstream out("cutii.out");
	in>>n>>t;
	for ( i=1; i<=t; i++ )
	{
		for ( j=1; j<=n; j++ )
			in>>T[j].x>>T[j].y>>T[j].z;
		sort(T+1,T+n+1,myfct);
		maxim=0;
		for ( j=1; j<=n;++j)
		{
			REZ[j]=0;
			for ( l=j; l>=1; --l )
				if ( T[j].y>T[l].y && T[j].z>T[l].z && REZ[l]+1>REZ[j] )
					REZ[j]=REZ[l]+1;
			if (REZ[j]>maxim)
				maxim=REZ[j];

		}
		out<<maxim+1<<"\n";
	}
	
	return 0;
}