#include<iostream> #include<algorithm> #define maxn 1000010 #define ll long long usingnamespacestd;
int n, h[maxn];
ll w(int i, int j){ return1ll * (h[i] + h[j]) * (j - i); }
int a[maxn], b[maxn]; ll ans; voidsolve(int l, int r, int L, int R){ if (l > r) return ; int m = l + r >> 1, p = L; ll res = 0; for (int i = L; i <= R && a[i] < b[m]; ++i) if (w(a[i], b[m]) > res) res = w(a[i], b[m]), p = i; ans = max(ans, res); solve(l, m - 1, L, p); solve(m + 1, r, p, R); }