1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 50; int n, ans, L, W;
struct node { int x_, y_; } a[maxn];
bool cmpx(node &x, node &y) { return x.x_ < y.x_; }
bool cmpy(node &x, node &y) { return x.y_ < y.y_; }
int main() { cin >> L >> W >> n; for (int i = 1; i <= n; ++i) cin >> a[i].x_ >> a[i].y_; a[++n] = {0, 0}, a[++n] = {0, W}, a[++n] = {L, 0}, a[++n] = {L, W}; sort(a + 1, a + 1 + n, cmpx); for (int i = 1; i < n; ++i) { int u = 0, d = W; for (int j = i + 1; j <= n; ++j) { int l = a[i].x_, r = a[j].x_; ans = max(ans, (r - l) * (d - u)); a[i].y_ <= a[j].y_ ? d = min(d, a[j].y_) : u = max(u, a[j].y_); } } sort(a + 1, a + 1 + n, cmpy); for (int i = 1; i < n; ++i) { int u = 0, d = L; for (int j = i + 1; j <= n; ++j) { int l = a[i].y_, r = a[j].y_; ans = max(ans, (r - l) * (d - u)); a[i].x_ <= a[j].x_ ? d = min(d, a[j].x_) : u = max(u, a[j].x_); } } cout << ans; return 0; }
|