Cod sursa(job #868523)

Utilizator AlexandruValeanuAlexandru Valeanu AlexandruValeanu Data 31 ianuarie 2013 10:33:45
Problema Cutii Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include<fstream>
#include <algorithm>

using namespace std;
typedef struct { long x,y,z; } punct;
long i,j,n,t,l,maxim;
long REZ[3505];
punct T[3505];
bool myfct ( punct a, punct b)
{
    if ( a.x < b.x )
        return 1;
    return 0;
}
int main()
{
    ifstream in("cutii.in");
    ofstream out("cutii.out");
    in>>n>>t;
    for ( i=1; i<=t; i++ )
    {
        for ( j=1; j<=n; j++ )
            in>>T[j].x>>T[j].y>>T[j].z;
        sort(T+1,T+n+1,myfct);
        maxim=0;
        for ( j=1; j<=n;++j)
        {
            REZ[j]=0;
            for ( l=j; l>=1; --l )
                if ( T[j].y>T[l].y && T[j].z>T[l].z && REZ[l]+1>REZ[j] )
                    REZ[j]=REZ[l]+1;
            if (REZ[j]>maxim)
                maxim=REZ[j];

        }
        out<<maxim+1<<"\n";
    }

    return 0;
}