Two villages are separated by a river that flows from the north to the south. The villagers want to build a bridge across the river to make it easier to move across the villages.
The river banks can be assumed to be vertical straight lines x = a and x = b (0 < a < b ).
The west village lies in a steppe at point O = (0, 0). There are n pathways leading from the village to the river, they end at points A i = (a, y i ). The villagers there are plain and simple, so their pathways are straight segments as well.
The east village has reserved and cunning people. Their village is in the forest on the east bank of the river, but its exact position is not clear. There are m twisted paths leading from this village to the river and ending at points B i = (b, y' i ). The lengths of all these paths are known, the length of the path that leads from the eastern village to point B i , equals l i .
The villagers want to choose exactly one point on the left bank of
river
A
i
, exactly one point on the right bank
B
j
and connect them by a straight-line bridge so as to make the
total distance between the cities (the sum of |OA
i
| + |A
i
B
j
| + l
j
, where |XY| is the
Euclidean distance between points
X
and
Y
) were minimum. The Euclidean distance between points (x
1, y
1) and (x
2, y
2) equals
.
Help them and find the required pair of points.
