Cod sursa(job #2282689)

Utilizator AlexandruabcdeDobleaga Alexandru Alexandruabcde Data 14 noiembrie 2018 12:43:31
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <fstream>

using namespace std;

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

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

cutie gigel[3505];

int n, T, Max[3505], lmax;

int main()
{
    f >> n >> T;

    for (; T; T--)
    {
        for (int i = 1; i <= n; i++)
        {
            f >> gigel[i].x >> gigel[i].y >> gigel[i].z;
        }

        for (int i = 1; i <= n; i++)
            Max[i] = 0;
        lmax = 0;

        for (int i = 1; i <= n; i++)
        {
            for (int j = i - 1; j >= 1; j--)
            {
                if (gigel[j].x < gigel[i].x && gigel[j].y < gigel[i].y && gigel[j].z < gigel[i].z) Max[i] = max(Max[i], Max[j]);
            }

            Max[i]++;
            if (Max[i] > lmax)
            {
                lmax = Max[i];
            }
        }

        g << lmax << '\n';
    }
    return 0;
}