# Eerie Planet

Problem:-

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.

Input:
First line of the input contains 3 integers,

$H,C,Q$

. Representing number of hours in a day, number of crew members and number of queries respectively.
Next C lines follow, where each line contains 3 integers,

${h}_{i},{S}_{i},{E}_{i}$

, representing height of the crew member and start and end hour of his/her work schedule. He/she works for hours

$\left[{S}_{i},{E}_{i}\right]$

, both inclusive.
Next Q lines follow, each containing 2 integers,

${h}_{i},{t}_{i}$

, representing height and time (in hour) of the person trying to enter the club.

Output:
Q lines, each line containing “YES” or “NO”, without the quotes, answering if the person will be allowed to enter the club or not.

Constraints:

$1\le H\le {10}^{9}$

$1\le C\le {10}^{5}$

$1\le Q\le {10}^{5}$

$1\le {S}_{i}\le {E}_{i}\le H$

$1\le {t}_{i}\le H$

$1\le {h}_{i}\le {10}^{7}$

Sample Input
`10 1 550 2 610 110 250 551 6100 10`
Sample Output
`YESNONOYESYES`
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

During the first hour, there is no crew member and hence person is allowed.
During hours 2 and 5, person is not taller than crew member, hence is not allowed to enter.
4th person is taller than the crew member at work and hence person is allowed.
During the 10th hour, there is no crew member and hence person is allowed.

Solution:-

#include<stdio.h>
int main()
{
long long int i,j,t,H,C,height,Q,S,E,h;
long long int nc=0,val=0,flag=0,maximum_height=0;
scanf(“%lld%lld%lld”,&H,&C,&Q);

for(i=0;i<C;i++)
{
scanf(“%lld%lld%lld”,&h[i],&S[i],&E[i]);
if(h[i]>maximum_height)
maximum_height=h[i];
}

for(i=0;i<Q;i++)
{
scanf(“%lld%lld”,&height,&t);
if(height>maximum_height)
printf(“YESn”);
else{
val=0;
nc=0;
flag=0;
for(j=0;j<C;j++)
{
if(t>=S[j] && t<=E[j])
{
nc++;
if(height<=h[j])
{
printf(“NOn”);
flag=1;
break;
}
else
val++;
}
}

if(nc==val)
printf(“YESn”);
else
if(flag==0)
printf(“NOn”);
}

}
return 0;
}