This page is still under construction.

Parts of this page are still being built. What you see may change.

Goat Ropes

Time limit8sMemory limit128 MB

Summary
Assign nonnegative radii to n points so that every pair satisfies r_i + r_j <= distance, and maximize the sum of all radii.
Level

Hard8 of 10

Topics
Graph, Minimum spanning tree, Greedy, Math
Solved
No attempts yet

Problem

A farmer has nn goats and, in the same field, nn fixed posts. He wants to tie each goat to a different post with a rope, giving every goat as much room to roam as possible. A goat tied to a post with a rope of length rr can graze anywhere inside the circle of radius rr centered at that post.

Goat ropes tangle easily, so no goat may ever be able to wander into another goat's grazing area: no two grazing circles may overlap, though they may just touch at a single point. Choosing the rope lengths under this rule, what is the maximum total length of rope the farmer can use?

Formally, assign a radius ri≥0r_i \ge 0 to each post ii so that ri+rj≤d(i,j)r_i + r_j \le d(i, j) for every pair of distinct posts i≠ji \ne j, where d(i,j)d(i, j) is the distance between them. Maximize ∑iri\sum_i r_i.

Input

The input contains several test cases. Each test case begins with an integer nn (2≤n≤502 \le n \le 50), the number of posts. Each of the next nn lines contains two integers xx and yy (0≤x≤10000 \le x \le 1000, 0≤y≤10000 \le y \le 1000), the Cartesian coordinates in meters of a post. No two posts share the same position. The field is large enough that the goats never reach its border. The input ends with a line containing a single 00.

Output

For each test case, output on its own line the maximum total length of rope the farmer could use, in meters, rounded to exactly two decimal places. Do not print any extra spaces, and do not print a blank line between answers.

Examples6

  1. Example 1

    Input
    2
    250 250
    250 750
    3
    250 250
    500 500
    250 750
    0
    
    Expected output
    500.00
    603.55
    
  2. Example 2

    Input
    2
    0 0
    1000 1000
    0
    
    Expected output
    1414.21
    
  3. Example 3

    Input
    4
    0 0
    0 10
    10 0
    10 10
    0
    
    Expected output
    20.00
    
  4. Example 4

    Input
    4
    0 0
    10 0
    20 0
    30 0
    0
    
    Expected output
    20.00
    
  5. Example 5

    Input
    5
    500 900
    880 624
    735 176
    265 176
    120 624
    0
    
    Expected output
    1175.54
    
  6. Example 6

    Input
    5
    0 0
    1000 0
    0 1000
    1000 1000
    500 500
    0
    
    Expected output
    2207.11