Cod sursa(job #195118)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 16 iunie 2008 19:54:44
Problema Cutii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 3.04 kb
program cutii;
{$APPTYPE CONSOLE}
uses
  SysUtils;
type cutie = record
        x,y,z,p:integer;
        ok,k:boolean;
end;
var r,g,j,max,o,q,s,t,c,i,n,m,b:integer;
    v:array [1..3500] of cutie;
    fin,fout:text;
{*---------------------------------------*}
begin
        assign(fin,'cutii.in'); reset(fin);
        assign(fout,'cutii.out'); rewrite(fout);
        readln(fin,n,t);
        for q:=1 to t do
        begin
                c:=0;
                For i:=1 to n do
                begin
                        readln(fin,v[i].x,v[i].y,v[i].z);
                        v[i].ok:=true; v[i].p:=0;
                        v[i].k:=true;
                end;

                for i:=1 to n do
                        //if v[i].ok then
                        begin
                                max:=-maxint; o:=0;
                                for j:=1 to n do
                                begin
                                        if (v[j].ok) and (i<>j) then
                                        begin
                                                s:=v[j].x+v[j].y+v[j].z;
                                                if (v[i].x>v[j].x) and (v[i].y>v[j].y) and (v[i].z>v[j].z) and (max < s) then
                                                begin
                                                        max:=s;
                                                        o:=j;
                                                end;
                                        end;
                                end;
                                if o > 0 then
                                begin
                                        if (v[i].p = 0) and (v[o].p =0) then
                                        begin
                                                inc(c);
                                                v[i].p:=c;
                                                v[o].p:=c;
                                        end
                                        else
                                        begin
                                                if v[i].p > 0 then v[o].p:=v[i].p
                                                else v[i].p:=v[o].p;
                                        end;
                                       // v[i].ok:=false;
                                        v[i].k:=false ;
                                        v[o].k:=false;
                                        v[o].ok:=false;//sa nu mai fie bagata in alta
                                        //v[o].ok:=false;
                                   //     c:=c+1;
                                end;
                        end;
                   g:=-1;//max
                   for i:=1 to c do
                   begin
                        r:=0;
                        for j:=1 to n do if v[j].p  = i then inc(r);
                        if g < r then g:=r;
                   end;
                   writeln(fout,g);

        end;


        close(fin);
        close(fout);
end.