Prime Cut 5
Kirby has to set up a space station to survey a set of n stars, each of which has a distinct position (xi,yi). To set up a space station, Kirby must choose a position on a cut in spacetime. This cut is a line segment that begins at position (s,0) and ends at (e,0), meaning that kirby can choose any position on the x axis between s and e for his space station.
The space station will send out a light beam to each star sequentially, starting with star 1, then 2, ... until it sends a signal to star n. When the station sends out a signal to a star i, it takes di seconds to reach the star, where di is the distance to the star from the space station. the signal then takes di seconds to travel back to the space station. Only then can the station send a signal to star i+1.
The amount of time taken to send and receive a signal from every star is a period, and can be expressed as 2d1+2d2+2d3...+2dn. Kirby wants to maximise the number of signals sent to stars, so he wants to choose a position for his station such that the period is small as possible. What is the smallest period that can be achieved?
hint: functions of the form f(x)=(x−a)/sqrt((x−a)2+b2) are monotonically increasing.
Input
The first line has 3 integers n,s,e,(1≤n≤1e5)(−1e5≤s,e≤1e5), the number of stars, and the start and end points of the cut in spacetime.
n lines follow, each with xiyi, the coordinates of a star −1e5≤xi,yi≤1e5.
All points are distinct and guaranteed to not be all collinear.
Output
Write the smallest possible period that occurs when kirby chooses the optimal location for a space station
Sample Input
2 -1000 1000
1 1
2 2
6.32455532
1 -2000 1000
5 5
10
7 -10 0
8 3
10 1
0 2
0 8
7 2
0 0
5 10
94.10865829
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.