Geometry
Geometry-17
Geometry-18
Geometry-19
~/algor $ cat problems/qavariq-qobiq-perimetri
Perimeter of the convex hull
Medium
1000 ms
128 MB
66%
$n$ points $(x_{1}; y_{1}), (x_{2}; y_{2}), \ldots, (x_{n}; y_{n})$ are given on the plane. Find the perimeter of the smallest convex polygon containing all the points (the convex hull). If all the points lie on one line, the perimeter is taken to be twice the distance between the two extreme points.
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.
Output
One number — the perimeter of the convex hull, with exactly $2$ digits after the decimal point (for example, 16.00).
Note
$1 \le n \le 10^{5}$
$-10^{9} \le x_{i}, y_{i} \le 10^{9}$
Examples
Input #1
5 0 0 4 0 4 4 0 4 2 2
Output #1
16.00
Input #2
3 0 0 3 0 0 4
Output #2
12.00