Cod sursa(job #2332095)

Utilizator mihai50000Mihai-Cristian Popescu mihai50000 Data 30 ianuarie 2019 13:18:31
Problema Cutii Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 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 n, t, k, i, j, mx;

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