Points and Line Segments#4430

Points and Line Segments

1 secundă
16 megabyți
Ușor

Given segments on a number line and points on the same line, your task is to determine how many of these segments each point belongs to.

A point is considered to belong to a segment defined by endpoints and if it satisfies the following condition:

\min(a, b) \leq x \leq \max(a, b).

Date de intrare

The first line contains two integers, and , representing the number of segments and the number of points, respectively (1 \leq N, M \leq 10^5). The next lines each contain two integers, a_i and b_i, which are the coordinates of the endpoints of the -th segment. The final line contains integers, which are the coordinates of the points. All numbers in the input are within the range of -10^9 to 10^9.

Date de ieșire

Print integers, where each integer corresponds to the number of segments that contain the respective point.

Exemple

Exemplul 1

Loading
Loading