답안 #92914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92914 2019-01-05T14:51:37 Z popovicirobert Hacker (BOI15_hac) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MAXN = (int) 5e5 + 5;

int arr[MAXN + 1], n;
int pref[MAXN + 1], suff[MAXN + 1];

inline int get(int l, int r) {
    if(l <= 0) {
        return suff[n + l] + pref[r];
    }
    if(r > n) {
        return suff[l] + pref[r - n];
    }
    return pref[r] - pref[l - 1];
}

/*inline bool ok(int l, int r) {
    return min(l, r)
}

inline bool check(int val, int len) {
    queue <int> q;
    int i, l;
    for(i = 1; i <= len; i++) {
        if(get(i - len + 1, i) > val) {
            l = ;
            q.push();
        }
    }
    if(ok(l, q.front())) {
        return 1;
    }
    for(i = 2; i <= n; i++) {

    }
    return 0;
}*/

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
        pref[i] = pref[i - 1] + arr[i];
    }
    for(i = n; i >= 1; i--) {
        suff[i] = suff[i + 1] + arr[i];
    }
    /*int res = 0;
    for(int step = 1 << 30; step; step >>= 1) {
        if(check(res + step, (n + 1) / 2)) {
            res += step;
        }
    }
    cout << res;
    */
    int len = (n + 1) / 2;
    int ans = 0;
    for(i = 1; i <= n; i++) {
        ans = max(ans, min(get(i - len + 1, i), get(i, i + len - 1)));
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -