답안 #884632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884632 2023-12-07T19:26:25 Z MisterReaper Hacker (BOI15_hac) C++17
100 / 100
261 ms 24420 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

const int INF = 1E9;

#define ONLINE_JUDGE
void solve() {
    int n;
    cin >> n;

    vector <int> a(2 * n +1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i + n] = a[i];
    }

    vector <int> pref = a;
    for(int i = 1; i <= 2 * n; i++) {
        pref[i] += pref[i -1];
    }

    auto get = [&](int x, int y) -> int {
        return pref[x] - pref[y -1];
    };

    vector <int> ans(n, INF);
    int sz = (n +1) / 2;
    multiset <int> ms;
    for(int i = 1; i <= 2 * n; i++) {
        if(i + sz -1 <= 2 * n) {
            ms.emplace(get(i + sz -1, i));
        }
        if(i - sz >= 1) {
            ms.erase(ms.find(get(i -1, i - sz)));
        }

        /*
        cerr << i << ":\n";
        for(const int &j : ms) {
            cerr << j << " ";
        }
        cerr << "\n";
        */
        
        ans[i % n] = min(ans[i % n], *ms.begin());
    }

    cout << *max_element(ans.begin(), ans.end());
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 856 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 29 ms 4276 KB Output is correct
5 Correct 86 ms 9820 KB Output is correct
6 Correct 123 ms 12284 KB Output is correct
7 Correct 131 ms 14596 KB Output is correct
8 Correct 261 ms 24148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 856 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 29 ms 4276 KB Output is correct
36 Correct 86 ms 9820 KB Output is correct
37 Correct 123 ms 12284 KB Output is correct
38 Correct 131 ms 14596 KB Output is correct
39 Correct 261 ms 24148 KB Output is correct
40 Correct 4 ms 860 KB Output is correct
41 Correct 7 ms 1368 KB Output is correct
42 Correct 10 ms 1908 KB Output is correct
43 Correct 85 ms 9936 KB Output is correct
44 Correct 248 ms 24324 KB Output is correct
45 Correct 35 ms 4952 KB Output is correct
46 Correct 140 ms 14668 KB Output is correct
47 Correct 239 ms 24400 KB Output is correct
48 Correct 202 ms 24420 KB Output is correct
49 Correct 179 ms 23552 KB Output is correct
50 Correct 172 ms 23540 KB Output is correct