eolymp
bolt
Try our new interface for solving problems
Problems

Unification Day

Unification Day

Byteland has $n$ cities, but no one road. The king of the country, Waldemar de Bear, decided to remedy this situation, he wants to connect some cities with roads so that along these roads it will be possible to reach any city from any other city. When construction will be completed, the king plans to celebrate the Unification Day. Unfortunately, the treasury in Byteland is almost empty, so the king needs to save money and minimize the total length of constructed roads. \InputFile The first line contains the number $n~(1 \le n \le 5000)$ of cities in Byteland. Each of the next $n$ lines contains two integers $x_i, y_i~(-10000 \le x_i, y_i \le 10000)$ --- the coordinates of $i$-th city. No two cities are located in one point. \OutputFile Print the least total roads length. Print the answer with the accuracy no less than $10^{-3}$. \includegraphics{https://static.e-olymp.com/content/23/23f970c1a8112013e639f0675c52aec2064c5364.gif}
Time limit 2 seconds
Memory limit 128 MiB
Input example #1
6
1 1
7 1
2 2
6 2
1 3
7 3
Output example #1
9.6568542495