Pagini recente » Cod sursa (job #939867) | Cod sursa (job #383031) | Cod sursa (job #953626) | Cod sursa (job #530595) | Cod sursa (job #290452)
Cod sursa(job #290452)
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.