cswork / OA打开练习工作台

VisaOA #4

Lamp Illumination Count

估计中等可在线判题

考点(AI 标注)前缀和区间二分查找

Each lamp lights the closed interval [l,r]; for each position p, count the lamps satisfying l≤p≤r.

输入格式

n,q (1≤n,q≤200000), followed by n lines of l,r (−10⁹..10⁹, l≤r), then q positions p. The ranges are site-added.

输出格式

Output the coverage count of each position, separated by spaces.

样例 1

输入:

2 2
1 5
3 7
4 6

输出:

2 1

样例 2

输入:

1 3
0 0
-1 0 1

输出:

0 1 0

样例 3

输入:

2 3
-5 2
2 9
2 3 -5

输出:

2 1 1