Cod sursa(job #308424)

Utilizator andrici_cezarAndrici Cezar andrici_cezar Data 27 aprilie 2009 08:54:04
Problema Hotel Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.99 kb
#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;
}