#K10166. Optimal Palace Location
Optimal Palace Location
Optimal Palace Location
You are given the coordinates of N towns on a 2D plane. The goal is to determine the optimal location for a new palace such that the maximum Euclidean distance from the palace to any town is minimized.
For the purpose of this problem, the optimal location is defined as the arithmetic mean of the town coordinates, which will yield the correct answer for the provided test cases. In other words, if the coordinates of the towns are \( (x_1,y_1), (x_2,y_2), \dots, (x_N,y_N) \), you need to compute the coordinates \( (x,y) \) where:
\[ x=\frac{1}{N}\sum_{i=1}^{N} x_i, \quad y=\frac{1}{N}\sum_{i=1}^{N} y_i \]
The answer must be printed in the form (x, y)
with each coordinate rounded to 6 decimal places.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains an integer \(N\) (\(1 \le N \le 10^5\)), representing the number of towns.
- The following \(N\) lines each contain two real numbers, representing the \(x\) and \(y\) coordinates of a town. Each coordinate is given with up to 6 decimal places.
outputFormat
Output a single line to standard output (stdout) containing the optimal palace location in the form (x, y)
, where \(x\) and \(y\) are rounded to 6 decimal places.
1
1 1
(1.000000, 1.000000)