#include #include class Point { public: int x,y; Point *next; Point *prev; Point *getPrecedingPoint(int x) { if (next == NULL || next->x >= x) { return this; } return next->getPrecedingPoint(x); } double getK() { return (next->y - this->y) / (next->x / this->x); } double getQ() { return this->y - getK() * this->x; } double getFX(int x) { double k = getK(); double q = getQ(); return k*x + q; } }; int main() { int pts; while (scanf("%d",&pts)==1) { Point array[pts]; Point *list = NULL; for (int i = 0; i < pts; i++) { scanf("%d %d",&(array[i].x), &(array[i].y)); if (list == NULL) { list = &(array[i]); } Point *p = list->getPrecedingPoint(array[i].x); if (p->next == NULL || p->getFX(array[i].x) < array[i].y) { if (p->next == NULL) { p->next = &(array[i]); array[i].prev = p; } else { array[i].next = p->next; p->next->prev = &(array[i]); p->next = &(array[i]); array[i].prev = p; while (!(p->getFX(p->x) < p->getFX(p->next->x))) { if (p == list) { list = &(array[i]); array[i].prev = NULL; break; } array[i].prev = p->prev; array[i].prev->next = &(array[i]); p->next = NULL; p ->prev = NULL; } } } } for (Point *current = list; list != NULL; list = list->next) { double optlen = sqrt((current->x * current->x) + (current->y * current->y)); if (current->prev != NULL) { } } } return 0; }