Cod sursa(job #2332084)

Utilizator mihai50000Mihai-Cristian Popescu mihai50000 Data 30 ianuarie 2019 13:05:12
Problema Cutii Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("cutii.in");
ofstream out("cutii.out");

struct Box
{
	int x, y, z;
};

bool cmp(Box a, Box b)
{
	return a.x < b.x;
}

const int DIM = 3507;

Box v[DIM];
int best[DIM];

int main()
{
	int n, t;
	in >> n >> t;
	
	while(t--)
	{
		for(int i = 1; i <= n; i++)
		{
			in >> v[i].x >> v[i].y >> v[i].z;
		}
		
		sort(v + 1, v + 1 + n, cmp);
		
		memset(best, 0, sizeof(best));
		
		int mx = 0;
		
		for(int i = 1; i <= n; i++)
		{
			best[i] = 1;
			
			for(int j = 1; j < i; j++)
				if(v[i].y > v[j].y && v[i].z > v[j].z)
				{
					best[i] = max(best[i], best[j] + 1);
					mx = max(mx, best[i]);
				}
		}
		
		out << mx << '\n';
	}
}