#include #include #include #include typedef struct { long long x, y; } point; double distance(point p, point q) { return sqrt((double)(p.x - q.x) * (p.x - q.x) + (double)(p.y - q.y) * (p.y - q.y)); } int is_above(point p, point q, point r) { if (p.x == q.x) { if (r.x == p.x) return 0; else if (r.x < p.x) return 1; else return -1; } if (p.x == r.x) { if (p.y < r.y) return 1; else if (p.y > r.y) return -1; else return 0; } point t; if (q.x < p.x) { t = q; q = p; p = t; } if ((q.y - p.y) * (r.x - p.x) < (r.y - p.y) * (q.x - p.x)) return 1; else if ((q.y - p.y) * (r.x - p.x) > (r.y - p.y) * (q.x - p.x)) return -1; else return 0; } // Twice of the area of the triangle pqr long long area_of_triangle(point p, point q, point r) { long long L, R, B, T; L = p.x; if (L > q.x) L = q.x; if (L > r.x) L = r.x; R = p.x; if (R < q.x) R = q.x; if (R < r.x) R = r.x; B = p.y; if (B > q.y) B = q.y; if (B > r.y) B = r.y; T = p.y; if (T < q.y) T = q.y; if (T < r.y) T = r.y; long long ans = (R - L) * (T - B) * 2 - (llabs(p.x - q.x) * llabs(p.y - q.y) + llabs(q.x - r.x) * llabs(q.y - r.y) + llabs(r.x - p.x) * llabs(r.y - p.y)); if (p.x != L && p.x != R && p.y != B && p.y != T) { if (is_above(q, r, p) == 1) { if ((q.x == L && q.y == B) || (q.x == R && q.y == T)) ans -= (p.x - L) * (T - p.y); else ans -= (R - p.x) * (T - p.y); } else { if ((q.x == L && q.y == B) || (q.x == R && q.y == T)) ans -= (R - p.x) * (p.y - B); else ans -= (p.x - L) * (p.y - B); } } else if (q.x != L && q.x != R && q.y != B && q.y != T) { if (is_above(r, p, q) == 1) { if ((r.x == L && r.y == B) || (r.x == R && r.y == T)) ans -= (q.x - L) * (T - q.y); else ans -= (R - q.x) * (T - q.y); } else { if ((r.x == L && r.y == B) || (r.x == R && r.y == T)) ans -= (R - q.x) * (q.y - B); else ans -= (q.x - L) * (q.y - B); } } else if (r.x != L && r.x != R && r.y != B && r.y != T) { if (is_above(p, q, r) == 1) { if ((p.x == L && p.y == B) || (p.x == R && p.y == T)) ans -= (r.x - L) * (T - r.y); else ans -= (R - r.x) * (T - r.y); } else { if ((p.x == L && p.y == B) || (p.x == R && p.y == T)) ans -= (r.x - L) * (r.y - B); else ans -= (R - r.x) * (r.y - B); } } return ans; } typedef struct { double key; int id; } data; void merge_sort(int n, data x[]) { static data y[200001] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } void chmax(long long* a, long long b) { if (*a < b) *a = b; } int main() { struct timeval tt; double beg, cur; gettimeofday(&tt, NULL); beg = tt.tv_sec + (double)tt.tv_usec / 1000000; int i, N; point p[200001]; data d[200001]; scanf("%d", &N); for (i = 1, p[0].x = 0, p[0].y = 0; i <= N; i++) { scanf("%lld %lld", &(p[i].x), &(p[i].y)); d[i-1].key = distance(p[0], p[i]); d[i-1].id = i; } merge_sort(N, d); int j; long long ans = 0; for (i = N - 1; i >= 0; i--) { for (j = i - 1; j >= 0; j--) { if (ans - d[i].key * d[j].key >= 0.0) break; chmax(&ans, area_of_triangle(p[0], p[d[i].id], p[d[j].id])); } gettimeofday(&tt, NULL); cur = tt.tv_sec + (double)tt.tv_usec / 1000000; if (cur - beg > 2.49) break; } printf("%lld\n", ans); fflush(stdout); return 0; }