VisaOA #4
Lamp Illumination Count
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & RangesBinary Search
Each lamp lights the closed interval [l,r]; for each position p, count the lamps satisfying l≤p≤r.
Input
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
Output the coverage count of each position, separated by spaces.
Example 1
Input:
2 2
1 5
3 7
4 6
Output:
2 1
Example 2
Input:
1 3
0 0
-1 0 1
Output:
0 1 0
Example 3
Input:
2 3
-5 2
2 9
2 3 -5
Output:
2 1 1
Editorial
Loading solution…