Cod sursa(job #2332086)

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

using namespace std;

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()
{
	freopen("cutii.in","r",stdin);
	freopen("cutii.out","w",stdout);
	int n, t;
	
	scanf("%d%d", &n, &t);
	
	while(t--)
	{
		for(int i = 1; i <= n; i++)
		{
			scanf("%d%d%d", &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]);
		}
		
		printf("%d\n",mx);
	}
}