eolymp
bolt
Try our new interface for solving problems
Problems

Fire Signals

Fire Signals

Captain Vrungel and his mate Lom were shipwrecked and got to an uninhabited island. While the captain sought for fresh water in the island jungle, Lom decided to make some fire signals on the beach. He wanted to burn them all at night to send a distress signal that could be seen from a ship. When captain Vrungel returned to the beach, Lom had already made \textbf{n} bonfires. Captain looked at the fires and said that if one set all fires in one line they could be seen not only from a ship but from an airplane too. Find the minimal total distance, that Lom’s fire signals should be moved to, to be set in one line. \InputFile First line contains the number of fire signals \textbf{n }(\textbf{2 }≤ \textbf{n }≤ \textbf{1000}). Each of the next \textbf{n }lines contains integers \textbf{x_i}, \textbf{y_i} that are the coordinates of \textbf{i}-th fire signal (-\textbf{10^6} ≤ \textbf{x_i}, \textbf{y_i} ≤ \textbf{10^6}). \OutputFile Output the minimal total distance that Lom should move his fire signals to. The answer must be given with absolute or relative error not exceeding \textbf{10^\{−6\}}.
Time limit 4 seconds
Memory limit 64 MiB
Input example #1
4
0 0
0 1
1 1
1 0
Output example #1
1.4142135624
Author P.Klimov, O.Soboleva
Source 2013 Petrozavodsk, Winter, Ural FU contest, Kontur Cup, Problem F