Cod sursa(job #290452)

Utilizator andrici_cezarAndrici Cezar andrici_cezar Data 27 martie 2009 22:57:30
Problema Hotel Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.17 kb
var f,g:text;
    i,lungmax,lung,n,p,a,b,c,o:longint;
    camere:array[1..60000]of byte;
begin
assign(f,'hotel.in');reset(f);
assign(g,'hotel.out');rewrite(G);
readln(f,n,p);
for i:=1 to p do
    begin
    read(f,a);
    if a=1 then begin
                read(f,b,c);
                o:=b;
                while o<=b+c-1 do
                      begin
                      camere[o]:=1;
                      o:=o+1;
                      end;
                end;
    if a=2 then begin
                read(f,b,c);
                o:=b;
                while o<=b+c-1 do
                      begin
                      camere[o]:=0;
                      o:=o+1;
                      end;
                end;
    if a=3 then begin
                lung:=0;
                lungmax:=0;
                for o:=1 to n do
                    if camere[o]=0 then lung:=lung+1
                    else begin if lung>lungmax then lungmax:=lung;
                        lung:=0;
                        end;
                if lung>lungmax then lungmax:=lung;
                writeln(g,lungmax);
                end;
    readln(f);
    end;
close(g);
end.