#include #include #include using si = int64_t; using ui = uint64_t; struct rational { ui whole, numerator, denominator; rational(ui numerator_, ui denominator_) : whole(numerator_ / denominator_), numerator(numerator_ % denominator_), denominator(denominator_) {} bool operator>(const rational &other) const { return whole > other.whole || (whole == other.whole && numerator * other.denominator > other.numerator * denominator); } }; struct vec { si x, y; vec operator+(const vec &o) const { return {x + o.x, y + o.y}; } vec operator-(const vec &o) const { return {x - o.x, y - o.y}; } si operator*(const vec &o) const { return x * o.x + y * o.y; } }; int main() { ui N; std::cin >> N; std::vector points(N); for (ui i = 0; i < N; ++i) std::cin >> points[i].x >> points[i].y; ui best = 0, peak = 1; rational bestHeight(0, 1); for (ui i = 0; i < N; ++i) { const vec &p1 = points[i]; const vec &p2 = points[(i + 1) % N]; vec norm{p1.y - p2.y, p2.x - p1.x}; ui distance = std::abs((points[peak] - p1) * norm), next, nextDistance; while ((nextDistance = std::abs((points[next = (peak + 1) % N] - p1) * norm)) >= distance) { peak = next; distance = nextDistance; } rational height(distance * distance, norm * norm); if (height > bestHeight) { best = i; bestHeight = height; } } std::cout << (best + 1); }