Pagini recente » Cod sursa (job #1503961) | Cod sursa (job #211182) | Cod sursa (job #1000570) | Cod sursa (job #2660762) | Cod sursa (job #290453)
Cod sursa(job #290453)
var f,g:text;
i,lungmax,lung,n,p,a,b,c,o:longint;
camere:array[1..100000]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.