#include #include #include using namespace std; typedef struct TREE { int X,Y,L,V; } tree; typedef struct POINT { int x,y; } point; point p[18]; point o[40]; int np,no; int ccw(point a, point b, point c) { return (c.x-a.x) * (c.y-b.y) - (c.x-b.x) * (c.y-a.y); } #define sqr(a) ((a)*(a)) void insert(int i) { while (no>=2 && ccw(o[no-2],o[no-1],p[i]) < 0) no--; o[no++]=p[i]; } void hull() { if (np==1) return; if (np==2) { o[0]=p[0]; o[1]=p[1]; no=2; return; } int i; o[0]=p[0]; o[1]=p[1]; no=2; for (i=2;i=0;i--) insert(i); } bool cmp(point a, point b) { if (a.x==b.x) return a.y < b.y; return a.x < b.x; } void sortp() { sort(p,p+np,cmp); } double fencelength() { if (np==1) return 0; double len; for (int i=1;i>1; } sortp(); hull(); double tmp=fencelength(); if (tmp<=canlength) { if (first) minlost = lostvalue; else if (lostvalue