// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x),__VA_ARGS__})
#define cmax(x,...) x=max({(x),__VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010
struct stmin {
vector<int> a, lg;
vector<vector<int>> dp;
stmin(vector<int> v) {
a = v;
build();
}
void build() {
int logn = log2(sz(a)) + 2;
dp.assign(sz(a), vector<int>(logn, 0));
rep(i, 0, sz(a)) dp[i][0] = a[i];
rep(j, 1, logn) {
rep(i, 0, sz(a)) {
dp[i][j] = min(dp[i][j-1], dp[min(i + (1 << (j-1)), sz(a)-1)][j-1]);
}
}
lg.resize(sz(a)+1); lg[1] = 0;
rep(i, 2, sz(a)+1) lg[i] = lg[i/2] + 1;
}
int query(int l, int r) {
int j = lg[r - l + 1];
return min(dp[l][j], dp[r - (1 << j) + 1][j]);
}
};
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n; cin >> n;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
stmin st(a);
function<int(int, int)> cdq = [&](int l, int r) {
if (l == r) return a[l];
int mid = (l + r) / 2;
int lc = cdq(l, mid), rc = cdq(mid+1, r);
set<int, greater<int>> s;
rep(i, l, r+1) if (a[i] <= min(a[mid], a[mid+1])) s.insert(a[i]);
int i = mid, j = mid+1, height = min(a[mid], a[mid+1]), cur = 2 * height;
for (auto it = s.begin(); it != s.end(); ++it) {
while (i-1 >= l && a[i-1] >= *it) --i, cmin(height, a[i]);
while (j+1 <= r && a[j+1] >= *it) ++j, cmin(height, a[j]);
cmax(cur, (j - i + 1) * height);
}
return max({lc, rc, cur});
};
int ans = cdq(0, n-1);
cout << ans << endl;
return 0;
}
Alright guys, took a plunge into betjee777. I must admit I was impressed after registration. Decent odds and smooth interface. Give it a try: betjee777
Win777slots? Dude, the name alone is worth a try. Hoping for some lucky spins over there! I’m ready at win777slots.
78winvn – the VN makes me wonder if it’s popular in Vietnam. But hey, wins are wins! Is it worth my time to check out from the states? Tell me your experiences!. 78winvn
Clubgameb66club? Sounds kinda sus, but not bad so far, a random internet friend gave it to me. If you are looking for a new place to burn some time, maybe it is you? Give it a try with this link: clubgameb66club
Alright, so I stumbled upon five888! Heard from someone in reddit. It’s got a decent selection of games. Not the flashiest site ever! Give it a shot: five888
Just stumbled across kl88. Seems alright, nothing too crazy. I tried it and it’s okay. kl88
Trying my luck with hbetvn now. Seems pretty straightforward, fingers crossed I win something big! Definitely worth a look see! hbetvn
Alright guys, gotta say I’ve been spinning the reels at jili222 and it’s been a blast! The games are pretty slick. Check it out! jili222
Hey, figured I’d share! Trying out lode789 and it’s got some solid options. Might be your next favorite! lode789
Heard some buzz about stakei777, figured I’d check it out. Solid site, nothing exceptional, but a decent experience. Roll the dice at stakei777!
Had a ripper time on kv888casino last night! Check out the slots and live dealer games. Join the fun: kv888casino
Heard good things about c99game, gives it a fair shake. Hopefully it is something good: c99game
[4765]1xbet Official Login Bangladesh | বিকাশ ডিপোজিট ও স্লট গেম,1xbet এর অফিশিয়াল লগইন করে সেরা স্লট গেম এবং ক্যাসিনোর অভিজ্ঞতা নিন। বিকাশ দিয়ে সহজ ডিপোজিট এবং অ্যাপ ডাউনলোড করে আজই শুরু করুন। visit: 1xbet
Best betting experience I have had in a while. The odds are fair and the customer support team is actually helpful. You guys should try 888fbbet.
The winning streaks here are insane. I managed to hit a big jackpot last night and the withdrawal was processed instantly. High praise for krcasinowinoui
Solid platform with a great selection of games. I’ve tried many others but this one feels the most professional. Check out bdz444 for a great time.