Minimum Diameter Sum
Time limit1sMemory limit512 MB
Split a set of n planar points into two nonempty groups so that the sum of the two group diameters is minimized, and print the value.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Sorting, Greedy
- Solved
- No attempts yet
Problem
A new city has many buildings. To make its administration efficient, the city splits the buildings into two groups, a red one and a blue one. The diameter of a group is the largest distance between two buildings of that group, and it measures how far the group spreads out. The smaller the diameter, the easier the administration. The goal is to find a split whose two diameters have the smallest possible sum.
Each building is a point in the plane, and the distance between two points is the Euclidean distance. The diameter of a point set is the largest distance between two points of the set. You are given a set of distinct points in the plane. Split into two subsets and with , , , , and make the diameter of plus the diameter of as small as possible. A subset that holds a single point has diameter .
For example, nine points with integer coordinates are given as in Figure 1(a). Many splits are possible. The split in Figure 1(b) gives the blue points a diameter of and the red points a diameter of , so the sum is . The split in Figure 1(c) has the sum , a bit smaller than the sum in Figure 1(b).

Figure 1. (a) The input points. (b), (c) Two splits. In each one the point pair that decides the diameter of a group is joined by a segment in the colour of that group.
Input
The first line holds the number of points ().
Each of the next lines holds one point. A line holds the coordinate and the coordinate of the point, separated by one space. Both values are integers between and , inclusive. The given points are distinct.
Output
Print the smallest possible sum of the two diameters, rounded to four digits after the decimal point. Always print exactly four digits after the decimal point. For example, if the answer is , print 2.0000.