#K68237. Optimal Library Position

    ID: 32820 Type: Default 1000ms 256MiB

Optimal Library Position

Optimal Library Position

You are given the coordinates of n homes in a 2D plane. Your task is to compute the optimal position for placing a library, such that the sum of the Euclidean distances from the library to each home is minimized. For this problem, the optimal position is defined as the arithmetic mean of the coordinates of all given homes, i.e.,

\(\left(\frac{\sum_{i=1}^{n} x_i}{n}, \; \frac{\sum_{i=1}^{n} y_i}{n}\right)\)

If no homes are provided, output None.

inputFormat

The input is provided through standard input (stdin) and has the following format:

  • The first line contains an integer n representing the number of homes.
  • Each of the next n lines contains two space-separated numbers representing the coordinates x and y of a home.

outputFormat

If at least one home is provided, output two numbers representing the optimal library position. The coordinates must be rounded to 4 decimal places, separated by a space.

If no homes are provided, print None (without quotes).

## sample
1
1 1
1.0000 1.0000