#C8193. Optimal Playground Location
Optimal Playground Location
Optimal Playground Location
You are given a set of existing playground coordinates on a 2D plane. Your task is to determine the optimal location for a new public playground such that the sum of Euclidean distances from the new playground to all existing playgrounds is minimized. In this problem, the optimal location is taken to be the arithmetic mean of all given coordinates.
In mathematical terms, if the coordinates are \((x_1,y_1), (x_2,y_2), \ldots, (x_N,y_N)\), then the solution is given by:
[ x = \frac{1}{N}\sum_{i=1}^{N} x_i, \quad y = \frac{1}{N}\sum_{i=1}^{N} y_i ]
If there is only one playground, then the new playground will be at the same coordinate.
inputFormat
The input is given from standard input (stdin) in the following format:
N x1 y1 x2 y2 ... xN yN
Here, N is an integer representing the number of existing playgrounds, and each of the next N lines contains two space-separated integers representing the x and y coordinates of a playground.
outputFormat
Output to standard output (stdout) two floating-point numbers which represent the coordinates of the optimal new playground. The coordinates should be printed in one line separated by a space. It is recommended to print the numbers with at least 6 decimal places precision.
## sample1
2 3
2.000000 3.000000
</p>