import
java.util.*;
import
java.lang.*;
import
java.io.*;
class
Point {
int
x, y;
Point(
int
x,
int
y) {
this
.x = x;
this
.y = y;
}
}
class
Main {
static
int
cross_product(Point o, Point a, Point b) {
return
(a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
}
static
List<Point> convex_hull(List<Point> points) {
int
n = points.size();
if
(n <=
3
)
return
points;
Collections.sort(points,
new
Comparator<Point>() {
@Override
public
int
compare(Point p1, Point p2) {
if
(p1.x == p2.x)
return
p1.y - p2.y;
return
p1.x - p2.x;
}
});
Point[] ans =
new
Point[
2
* n];
int
k =
0
;
for
(
int
i =
0
; i < n; i++) {
while
(k >=
2
&& cross_product(ans[k-
2
], ans[k-
1
], points.get(i)) <=
0
)
k--;
ans[k++] = points.get(i);
}
int
t = k +
1
;
for
(
int
i = n-
2
; i >=
0
; i--) {
while
(k >= t && cross_product(ans[k-
2
], ans[k-
1
], points.get(i)) <=
0
)
k--;
ans[k++] = points.get(i);
}
List<Point> result =
new
ArrayList<>();
for
(
int
i =
0
; i < k-
1
; i++)
result.add(ans[i]);
return
result;
}
static
double
dist(Point a, Point b) {
return
Math.sqrt(Math.pow(a.x - b.x,
2
) + Math.pow(a.y - b.y,
2
));
}
static
double
perimeter(List<Point> points) {
int
n = points.size();
double
perimeter =
0.0
;
for
(
int
i =
0
; i < n-
1
; i++)
perimeter += dist(points.get(i), points.get(i+
1
));
perimeter += dist(points.get(
0
), points.get(n-
1
));
return
perimeter;
}
public
static
void
main(String[] args)
throws
java.lang.Exception {
List<Point> points =
new
ArrayList<>();
points.add(
new
Point(
0
,
3
));
points.add(
new
Point(
2
,
2
));
points.add(
new
Point(
1
,
1
));
points.add(
new
Point(
2
,
1
));
points.add(
new
Point(
3
,
0
));
points.add(
new
Point(
0
,
0
));
points.add(
new
Point(
3
,
3
));
List<Point> convex_points = convex_hull(points);
System.out.println(perimeter(convex_points));
}
}