Pagini recente » Cod sursa (job #2773200) | Cod sursa (job #1527785) | Cod sursa (job #530355) | Cod sursa (job #2407996) | Cod sursa (job #2791104)
#include <bits/stdc++.h>
using namespace std;
int N, P, c, ind, M;
vector<int> vect;
void sosesteGrup()
{
int sf = ind + M-1;
for(int i=ind; i<=sf; i++)
vect[i] = 0;
}
void pleacaGrup()
{
int sf = ind + M -1;
for(int i=ind; i<=sf; i++)
vect[i] = 1;
}
int maxim()
{
int maxi = 0, auxMax = 0;
for(int i=1; i<=N; i++)
{
if(vect[i] == 1)
auxMax++;
if(vect[i] == 0)
{
if(auxMax > maxi)
maxi = auxMax;
auxMax = 0;
}
}
if(!maxi)
return auxMax;
return maxi;
}
int main()
{
ifstream fin("hotel.in");
ofstream fout("hotel.out");
fin>>N>>P;
vect = vector<int> (N+1, 1);
for(; P; P--)
{
fin>>c;
if(c == 1)
{
fin>>ind>>M;
sosesteGrup();
}
if(c == 2)
{
fin>>ind>>M;
pleacaGrup();
}
if(c == 3)
fout<<maxim()<<endl;
//cout<<maxim()<<endl;
}
return 0;
}