Hasan and Points Pairing
Basic programming
Medium
Ready
45.0% success
1,088 attempts
1s time
256MB memory
1024KB max code

Hasan is feeling bored since he has been studying for his physics exam all day, that's why he started to do random stuff, he drew 2*N points on piece of paper, coordinates of i-th point is (Xi, Yi) and now he is wondering how to connect the points with N segments of minimum possible sum of lengths such that:

  • No two segments intersect.
  • And each point is an endpoint of exactly one segment .

(Yes, studying for exams made Hasan bored enough to wonder about weird questions) Help Hasan by answering his question so that he can continue to study for his exam.

Input format:

First line contain one integer N.
Next 2*N lines contains two integers each, i-th line contains coordinates of i-th point Xi and Yi.

Output format:

Output one number, the minimum sum of lengths of non-intersecting segments rounded to exactly 6 digits after floating point.

Constraints:

  • 1<= N <= 8
  • 0 <= Xi, Yi <= 1,000
Examples
Input
2
0 1
2 0
2 1
0 0
Output
2.000000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...