| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1270615 | skibidihehe | Network (BOI15_net) | C++20 | 0 ms | 320 KiB | 
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define taskname ""
#define ld long double
const int mod = 1e9+7;
using namespace std;
#define int ll
int n, a[1000009], f[1000009][29];
int query(int l, int r){
    int z = r - l + 1;
    int cnt = 0;
    while((1ll << cnt) <= z){
        cnt++;
    }
    cnt--;
    return min(f[l][cnt], f[r - (1 << cnt) + 1][cnt]);
}
signed main() {
    if (fopen(taskname".inp","r")) {
        freopen(taskname".inp","r",stdin);
        freopen(taskname".out","w",stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = n + 1; i <= 2ll * n; i++){
        a[i] = a[i - n];
    }
    int cnt = (n + 1) / 2;
    for(int i = 1; i <= 2 * n; i++){
        a[i] += a[i - 1];
    }
    for(int i = cnt; i <= 2ll * n; i++){
        f[i][0] = a[i] - a[i - cnt];
    }
    for(int i = 1; i < 20; i++){
        for(int j = cnt; j <= 2 * n; j++){
            if(j + (1ll << i) <= 2ll * n){
                f[j][i] = min(f[j][i - 1], f[j + (1 << (i - 1))][i - 1]);
            }
        }
    }
    int ans = 0;
    for(int i = cnt; i <= 2ll * n; i++){
        ans = max(ans, query(i - cnt + 1, i));
    }
    cout << ans;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
