Answer to Question #271072 in C++ for Jzjsjsn

Question #271072

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.

1
Expert's answer
2021-11-25T00:53:16-0500

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;

}

}

}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS