Tidying up
Time limit2sMemory limit512 MB
Place N points so the configuration is symmetric about the y-axis with equal multiplicities; minimize the total Euclidean distance moved.
Problem
Objects lie scattered on the floor of a room. Let be the straight line that cuts the room exactly in half. The room is tidy when, for every position that holds an object, the position mirrored across also holds an object, and both positions hold the same number of objects.
Carrying objects around is hard work, so you move them one at a time and keep the total carried distance as small as possible. Distance walked while carrying nothing does not count.
In this problem is the axis, and the position of each object is given as a point on the plane. Find the smallest possible sum of the distances the objects travel when the room ends up tidy. Distance is the Euclidean distance . An object may be put down at a position with non-integer coordinates.

For example, with the objects placed as in the picture above, moving the right object down by 1 makes the room tidy, and the total distance is 1.
Input
The first line has the number of objects (). Each of the next lines has the position of one object as . Both coordinates are integers between and . No two objects start at the same position.
Output
Print the smallest possible sum of the travel distances after the room is tidy, rounded to three decimal places. Print all three digits after the decimal point even when the value is an integer.