Do the Times Overlap?
InterviewTime limit1sMemory limit512 MB
Given N closed time intervals [S, E] of seat use, count how many intervals contain each queried time t.
- Level
Easy3 of 10
- Topics
- Prefix sum, Sorting, Binary search
- Solved
- No attempts yet
Problem
Not long ago, a question appeared on the Pusan National University community board asking which time slots have the most empty seats in the library reading room.
The poster asked students to reply with when they used the reading room last Sunday.
Many students replied with the times they were there.
Pusan National University students do not leave their assigned seats during study hours.
A seat cannot be selected at the moment its use ends.
For convenience, times are given from to in integer units. Find the number of seats that cannot be selected at each given time.
Input
The first line contains , the number of students who replied.
Each of the next lines contains , the start time of a student's seat use, and , the end time.
The next line contains , the number of times to check.
The next line contains the times to check.
Output
For each given time, print the number of seats that cannot be selected at that time, in the given order, one per line.