Code:
#include <bits/stdc++.h>
using namespace std;
const int maxn=10010;
const double pi=acos(1.0);
struct node {
double x,y;
}p[maxn],P[maxn];
int n;
double ans=0;
inline double X_(node A,node B,node C) {
double x11=B.x-A.x;
double x22=C.x-A.x;
double y11=B.y-A.y;
double y22=C.y-A.y;
return ( (x11*y22) - (y11*x22) );
}
inline double len_(node A,node B) {
return sqrt( (A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y) );
}
inline bool cmp_(node A,node B) {
double pp=X_(p[0],A,B);
if(pp>0) return true;
if(pp<0) return false;
return len_(p[0],A)<len_(p[0],B);
}
int main() {
scanf("%d",&n);
if(!n) printf("\n");
else {
for(int i=0;i<n;i++) {
scanf("%lf%lf",&p[i].x,&p[i].y);
if(p[i].y<p[0].y) swap(p[i],p[0]);
}
}
sort(p+1,p+n,cmp_);
P[0]=p[0];P[1]=p[1];
int cnt=1;
for(int i=2;i<n;i++) {
while(cnt&&X_(P[cnt-1],P[cnt],p[i])<=0) --cnt;
++cnt;
P[cnt]=p[i];
}
for(int i=0;i<cnt;i++) {
ans+=len_(P[i],P[i+1]);
}
ans+=len_(P[0],P[cnt]);
printf("%.2lf",ans);
return 0;
}