Masala #5MVOGITWOZ
Perfectionist
There are n points on the plane. You can move a point from a coordinate \((x_1, y_1) \) to the coordinate \((x_2, y_2)\) за стоимость, равную \(\sqrt{(x_1 - x_2)^2 + (y_1 - y_2) ^ 2}\)
Your task is to minimize the total cost of moving all points in such a way that they lie on the same straight line. Note that you can move the points in any way you like.
The first line contains an integer \(n\) — number of points \((2 <= n <= 10^3)\). Next in \(n\) the lines list the coordinates of these points\(x_i\)and \(y_i\) — integers, modulo not exceeding \(10^6\)
Print the minimum total distance to which the points should be dragged, with an absolute or relative error of no more than \(10^{-6}\)
# | input.txt | output.txt |
---|---|---|
1 |
4 0 0 0 1 1 1 1 0 |
1.414214 |