you own a club on eerie planet. the day on this planet comprises of h hours. you appointed c crew members to handle the huge crowd that you get, being the best club on the planet. each member of the crew has fixed number of duty hours to work. there can be multiple or no crew members at work at any given hour of the day. being on weird planet, the rules of this club cannot be normal. each member of the crew only allows people who are taller than him to enter the club when he is at work. given the schedule of work and heights of the crew members, you have to answer q queries. each query specifies the time of entry and height of a person who is visiting the club. you have to answer if the person will be allowed to enter the club or not.
SOLUTION
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
class crew
{
public:
int height;
int start;
int last;
};
class people
{
public:
int customerHeight;
int enteringTime;
};
int main()
{
int totalHours, crewMembers, peopleVisiting;
cin>>totalHours>>crewMembers>>peopleVisiting;
crew obj1[crewMembers];
for(int i=0;i<crewMembers;i++)
{
cin>>obj1[i].height;
cin>>obj1[i].start;
cin>>obj1[i].last;
}
people obj2[peopleVisiting];
int flag = 0;
for(int i=0;i<peopleVisiting;i++)
{
cin>>obj2[i].customerHeight;
cin>>obj2[i].enteringTime;
for(int j=0;j<crewMembers;j++)
{
if(obj1[j].start <= obj2[i].enteringTime &&
obj2[i].enteringTime <= obj1[j].last)
{
if(obj2[i].customerHeight <= obj1[j].height)
{
cout<<"NO"<<endl;
flag = 1;
break;
}
}
}
if(flag == 0)
{
cout<<"YES"<<endl;
}
else
{
flag = 0;
}
}
}
Comments
Leave a comment