Pagini recente » Cod sursa (job #1707920) | Cod sursa (job #2976183) | Cod sursa (job #305163) | Cod sursa (job #225754) | Cod sursa (job #2406511)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out");
struct cut{
int x, y, z;
}cutii[3505];
bool operator<(cut a, cut b)
{
return a.x*a.y*a.z>b.x*b.y*b.z;
}
int dp[3505], n, t, maxi;
void citire(int ind)
{
f >> cutii[ind].x >> cutii[ind].y >> cutii[ind].z;
dp[ind]=0;
}
bool e_bine(cut a, cut b)
{
if (b.x>a.x && b.y>a.y && b.z>a.z)
return true;
return false;
}
void solve()
{
dp[1]=1;
for (int i=2; i<=n; ++i)
{
for (int j=i-1; j>0; --j)
{
if (dp[j]+1>dp[i] && e_bine(cutii[i],cutii[j]))
{
dp[i]=dp[j]+1;
maxi=max(maxi,dp[i]);
}
}
}
}
int main() {
f >> n >> t;
for (int test=1; test<=t; ++test)
{
for (int i=1; i<=n; ++i)
{
citire(i);
}
maxi=0;
sort(cutii+1,cutii+n+1);
solve();
g << maxi << '\n';
}
return 0;
}