답안 #723582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723582 2023-04-14T05:44:20 Z Mr_Husanboy Hacker (BOI15_hac) C++17
20 / 100
184 ms 2632 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int inf = 1e9;


void solve(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i ++) cin >> p[i];
    int ans = 0;
    for(int i = 1; i < n; i ++){
        p[i] += p[i - 1];
    }
    auto get = [&](int l, int r)->int{
        if(l > r){
            return p[r] + p[n - 1] - (l ? p[l - 1] : 0);
        }
        return p[r] - (l ? p[l - 1] : 0);
    };
    int k = (n + 1) / 2;
    for(int i = 0; i < n; i ++){
        int mn = inf;
        for(int j = i; j < i + k; j ++){
            int r = j % k;
            int l = ((r - k + 1) % n + n) % n;
            mn = min(mn, get(l, r));
        }
        ans = max(ans, mn);
        if(n > 5000) break;
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcases = 1;

    while(testcases --){
        solve();
        if(testcases) cout << '\n';
        #ifdef LOCAL
        else cout << '\n';
        cout << "__________________________" << endl;
        #endif
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 316 KB Output is correct
3 Correct 184 ms 344 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 14 ms 1620 KB Output is correct
6 Correct 21 ms 1668 KB Output is correct
7 Correct 24 ms 1856 KB Output is correct
8 Correct 39 ms 2632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -