Rice Hub (Riceway)
In the countryside there is a straight road called the Rice Way along which there are R rice fields.
Each field i is located at coordinate X[i], where
1 ≤ X[0] ≤ X[1] ≤ ... ≤ X[R-1] ≤ L.
We want to build a single Rice Hub at some coordinate H.
We have a transport budget B.
The cost to transport one truckload of rice from field i to the hub H is
|X[i] - H|.
Goal: Strategic Placement
Your program must find the maximum number of fields from which we can transport rice to a single hub location without exceeding our budget B.
Input constraints
Number of fields (R)
1 to 100,000
Max Coordinate (L)
1 to 1,000,000,000
Budget (B)
0 to 2 × 1015
Coordinates (X[i])
Sorted integers