Cod sursa(job #397900)

Utilizator tiger.snow1Iacob Andrei tiger.snow1 Data 17 februarie 2010 17:37:13
Problema Hotel Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include<fstream>
using namespace std;
#define N 5000
ifstream in("hotel.in");
ofstream out("hotel.out");
int cam[N],n;
int secv()
{
	int i,lmax=0,l;
	for(i=1;i<=n;i++)
		{     l=0;
			while((cam[i]==0)&&(i<=n))
			{
				l++;
				i++;
			}
			if(l>lmax)lmax=l;
		}
	return lmax;
}
int main()
{
	int p,c,k,t;
	in>>n>>p;
	int i;
	for(i=1;i<=p;i++)
	{
		in>>c;
		if(c==1)
		{
			in>>k>>t;
			for(int j=k;j<=k+t-1;j++)
				cam[j]=1;
		}
		if(c==2)
		{
			in>>k>>t;
			for(int j=k;j<=k+t-1;j++)
				cam[j]=0;
		}
		if(c==3)
		{
			out<<secv()<<'\n';
		}
	}
	in.close();
	out.close();
	return 0;
}