#include #include #include #include #include using namespace std; #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() struct pt { double x, y; pt() {} pt(double _x, double _y) : x(_y), y(_y) {} pt operator-(const pt &p) const { return pt(x-p.x, y-p.y); } double len() { return sqrt(x*x+y*y); } }; inline double cross(const pt &p1, const pt &p2) { return p1.x*p2.y-p1.y*p2.x; } const double eps = 1e-6; int n; vector stack; vector pts; pt p0; bool debug(double a) { cout <<"Debug: " < eps) || ( (fabs(p1.x*p2.y - p2.x*p1.y) < eps) && (p1.len() < p2.len()) ); } double build() { int imostLeft = 0; for(int i = 1; i < n; i++) { if((pts[i].x < pts[imostLeft].x) || ((pts[i].x == pts[imostLeft].x) && (pts[i].y < pts[imostLeft].y))) { imostLeft = i; } } p0 = pts[imostLeft]; pts.erase(pts.begin() + imostLeft), n--, stack.pb(p0); sort(all(pts), cmp); //[&](pt &p1, pt &p2) { return (abs((p1.y-p0.y)*(p2.x-p0.x) - (p1.x-p0.x)*(p2.y-p0.y)) > eps) ? ((p1.y-p0.y)*(p2.x-p0.x) < (p1.x-p0.x)*(p2.y-p0.y)) : ((p1-p0).len() < (p2-p0).len()); }); //debug(abs((pts[1].y-p0.y)*(pts[2].x-p0.x) - (pts[1].x-p0.x)*(pts[2].y-p0.y))); stack.pb(pts[0]); for(int i = 1; i < n; i++) { pt pcur = pts[i]; while(stack.size() > 1) { pt ptop = stack.back(); pt prev = *(stack.end() - 2); if(cross(pcur-ptop, prev-ptop) > eps) { break; } stack.erase(stack.end() - 1); } stack.pb(pcur); } n = (int)stack.size(); double ans = 0; for(int i = 0; i < n; i++) { ans += (stack[i]-stack[(i+1)%n]).len(); } return ans; } int main() { //freopen cin >>n; pts.resize(n); for(int i = 0; i < n; i++) { cin >>pts[i].x >>pts[i].y; } double ans = build(); cout <