Signals 2
Time limit1.5sMemory limit256 MB
Choose a subset of points with distinct x coordinates, sort them by x, and maximize the total Euclidean distance between consecutive chosen points.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Geometry, Sorting, Divide and conquer
- Solved
- No attempts yet
Problem
There are signals on the coordinate plane. Signal sits at , and no two signals share a position.
You build a communication system out of some of the signals. Line the chosen signals up in increasing order of coordinate and connect each neighboring pair in turn, so the chosen signals must all have different coordinates. The length of the system is the sum of the Euclidean lengths of the connecting segments. A system built from a single signal has length .
A longer system carries the transmission further. Find the length of the longest communication system.
Input
The first line contains the number of signals . ()
Each of the next lines contains the coordinates and of one signal, separated by a space. (, and and are integers)
Output
Print the length of the longest communication system on one line, rounded to seven digits after the decimal point. Pad with zeros so that seven digits always follow the decimal point.