#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
constexpr int INF = 1ull << 60;
int widths[200000 + 5], heights[200000 + 5];
struct Node {
Node *left = nullptr, *right = nullptr;
int l, r, m;
int width, height;
Node(int a, int b) {
l = a, r = b, m = (l + r) >> 1;
if (l == r) {
width = widths[l];
height = heights[l];
}
else {
left = new Node(l, m);
right = new Node(m + 1, r);
width = min(left->width, right->width);
height = min(left->height, right->height);
}
}
pair<int, int> rmq(int a, int b) {
if (a <= l && r <= b) return pair{width, height};
if (r < a || b < l) return {INF, INF};
auto [lw, lh] = left->rmq(a, b);
auto [rw, rh] = right->rmq(a, b);
return pair{min(lw, rw), min(lh, rh)};
}
};
Node *segtree;
int N;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> N;
for (int i = 0; i < N; ++i) cin >> widths[i] >> heights[i];
segtree = new Node(0, N - 1);
int ans = -1;
for (int i = 0; i < N; ++i) {
for (int j = i; j < N; ++j) {
auto [width, height] = segtree->rmq(i, j);
ans = max(ans, width * height * (j - i + 1));
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |