How Many Intervals Cover X
N intervals [L, R] over coordinates 1..105 are given, then Q point queries: how many intervals contain the point X?
Input: the first line has N and Q; the next N lines have the intervals; the next Q lines each have one X.
Output: Q lines with the coverage counts.
Constraints:
- 1 ≤ N, Q ≤ 105
- 1 ≤ L ≤ R ≤ 105
Sample Tests
Input 1
2 2 1 5 3 8 4 9
Output 1
2 0
Input 2
1 1 2 2 2
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.