#P5867. Fishing Frenzy
Fishing Frenzy
Fishing Frenzy
In this problem, you are given a set of fishes and fishermen. The sea is represented by the first quadrant of the Cartesian coordinate system. There are (n) fishes in the sea, and each fish is located at coordinates ((a, b)) (note that several fishes can share the same point). On the shore (the x-axis), there are (m) fishermen. Each fisherman is located at coordinate ((x, 0)). Each fisherman owns a fishing rod of length (l) and can catch any fish that is within a Manhattan distance of (l). The Manhattan distance between a fisherman at ( (x,0) ) and a fish at ( (a,b) ) is given by: [ |a - x| + b \le l ] Your task is to determine, for each fisherman, how many fishes he can catch.
inputFormat
The first line contains three integers \(n\), \(m\), and \(l\) \( (1 \le n, m \le 10^5,\ 1 \le l \le 10^9)\) representing the number of fishes, the number of fishermen, and the length of the fishing rod respectively.
The next \(n\) lines each contain two integers \(a\) and \(b\) \( (1 \le a, b \le 10^9)\), representing the coordinates of a fish.
The last line contains \(m\) integers, each representing the x-coordinate of a fisherman. All fishermen are located on the x-axis (i.e., y-coordinate is 0).
outputFormat
Output a single line containing \(m\) integers. The \(i\)-th integer denotes the number of fishes that the \(i\)-th fisherman can catch.
sample
3 2 4
1 2
2 1
3 3
2 4
3 2