Pagini recente » Cod sursa (job #44525) | Cod sursa (job #1908596) | Cod sursa (job #2048456) | Cod sursa (job #2423154) | Cod sursa (job #308424)
Cod sursa(job #308424)
#include<fstream.h>
long i,u,lungmax,lung,n,p,a,b,c,o;
short cam[100000];
int main()
{
ifstream f("hotel.in");
ofstream g("hotel.out");
f>>n>>p;
for (i=1;i<=p;i++)
{
u=a;
f>>a;
if (a==1)
{
f>>b>>c;
o=b;
while (o<=b+c-1)
{
cam[o]=1;
o++;
}
}
else if (a==2)
{
f>>b>>c;
o=b;
while (o<=b+c-1)
{
cam[o]=0;
o++;
}
}
else if (a==3)
{
if (u!=3)
{
lung=0;
lungmax=0;
for (o=1;o<=n;o++)
if (cam[o]==0) lung++;
else {
if (lung>lungmax) lungmax=lung;
lung=0;
}
if (lung>lungmax) lungmax=lung;
}
g<<lungmax<<'\n';
}
}
g.close();
return 0;
}