All Tracks Data Structures Queues Basics of Queues Problem

Eerie Planet
Tag(s):

Medium, Priority queue, Queue, Queue

Problem
Editorial
Analytics

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 \([S_i, E_i]\), 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 5
50 2 6
10 1
10 2
50 5
51 6
100 10
SAMPLE OUTPUT
YES
NO
NO
YES
YES
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.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

December Easy '17

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?