Cod sursa(job #2202670)

Utilizator IustinPetrariuIustinian Petrariu IustinPetrariu Data 9 mai 2018 16:55:51
Problema Cutii Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.1 kb
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#define NMAX 4501
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
struct date
{
    int x,y,z,total;
};
vector < date > answer;
int N,M,BEST[NMAX],mx,T;
int compara(const date &a, const date &b)
{
    return (a.total < b.total);
}
bool interior(const date &a, const date &b)
{
    return (a.x < b.x && a.y < b.y && a.z < b.z);
}
int main()
{
    fin>>N>>T;
    for(int i =1; i <= T; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            date c;
            fin>>c.x>>c.y>>c.z;
            c.total=c.x*100+c.y*10+c.z;
            answer.push_back(c);
        }
        sort(answer.begin(), answer.end(), compara);
        for(int j = 0 ; j < N; j++) BEST[j]=1;
        for(int j = 1; j < N; j++)
            for(int k = 0 ; k < j ; k++)
            if(interior(answer[k],answer[j]) && BEST[k] >= BEST[j])
        {
            BEST[j]=BEST[k]+1;
            mx=max(mx,BEST[j]);
        }
        fout<<mx<<'\n';
        mx=0;
        answer.clear();
    }

}