A and B are two cities distance units away from each other. Several transmitters have been placed along the straight road connecting them.
The transmission range can be set to any positive integer value, but it must be the same for all transmitters.
Any two transmitters can communicate directly if the distance between them is not greater than the transmission range.
Each transmitter can communicate with city A or city B if the distance between the transmitter and the city is not greater than the transmission range.
You have been assigned to set up a connection between the cities. You are allowed to move any number of transmitters, but moving a transmitter for k units costs you k dollars and the budget does not allow you to spend more than funds dollars in total. You can move the transmitters into points with integer coordinates only.
You will be given a int[] position, with the i-th element of position representing the initial distance between the i-th transmitter and city A. You will be also given funds, the maximal total cost you are allowed to spend when moving transmitters.
Return the minimal transmission range which still allows you to establish a connection between the cities. See notes for the formal definition of the connection.
|