답안 #866138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866138 2023-10-25T13:15:35 Z Ellinor Hacker (BOI15_hac) C++14
100 / 100
294 ms 22536 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast,inline") // Ofast = O3,fast-math,allow-store-data-races,no-protect-parens
#pragma GCC optimize ("unroll-loops")

#pragma GCC target("bmi,bmi2,lzcnt,popcnt")                      // bit manipulation
#pragma GCC target("movbe")                                      // byte swap
#pragma GCC target("aes,pclmul,rdrnd")                           // encryption
#pragma GCC target("avx,avx2,f16c,fma,sse3,ssse3,sse4.1,sse4.2")

typedef long long ll;
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define rrep(i, a, b) for (int i = (a) - 1; i >= int(b); i--)
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) x.begin(), x.end()

inline void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }

ll INF = 1000000000;
ll mod = 1e9 + 7;

#define int ll
#define float double

//

int N;
vector<int> ns;
vector<pii> splits;

int32_t main()
{
    fast();
    cin >> N;
    ns.assign(N, -1);
    rep(i,0,N) {
        cin >> ns[i];
    }

    int hn = N / 2;
    int sum1 = 0, sum2 = 0;
    rep(i,0,hn) {
        sum1 += ns[i];
    }
    rep(i,hn,N) {
        sum2 += ns[i];
    }

    rep(i,0,N) {
        splits.pb({sum1, sum2});
        //
        sum2 += ns[i];
        sum1 -= ns[i];
        sum1 += ns[(i + hn) % N];
        sum2 -= ns[(i + hn) % N];
        //
    }

    int bans = 0;
    multiset<int> s;
    rep(i,0,N % 2 ? hn + 1 : hn) {
        s.insert(splits[i].second);
    }

    // rep(i,0,N) {
    //     cerr << splits[i].first << " " << splits[i].second << "\n";
    // }

    rep(i,0,N % 2 ? 2*N : N)
    {
        // cerr << "*";
        auto x = s.begin();
        int ans = *x;
        bans = max(bans, ans);

        if (N % 2) {
            s.erase(s.lower_bound(splits[i % N].second));
            s.insert(splits[(i + hn + 1) % N].second);
        }
        else {
            s.erase(s.lower_bound(splits[i % N].second));
            s.insert(splits[(i + hn) % N].second);
        }
    }

    cout << bans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 420 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 420 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 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 348 KB Output is correct
25 Correct 2 ms 656 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 456 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 27 ms 3796 KB Output is correct
5 Correct 79 ms 8912 KB Output is correct
6 Correct 105 ms 11216 KB Output is correct
7 Correct 128 ms 13520 KB Output is correct
8 Correct 252 ms 21964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 420 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 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 348 KB Output is correct
25 Correct 2 ms 656 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 456 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 1 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 27 ms 3796 KB Output is correct
36 Correct 79 ms 8912 KB Output is correct
37 Correct 105 ms 11216 KB Output is correct
38 Correct 128 ms 13520 KB Output is correct
39 Correct 252 ms 21964 KB Output is correct
40 Correct 3 ms 824 KB Output is correct
41 Correct 7 ms 1248 KB Output is correct
42 Correct 10 ms 1624 KB Output is correct
43 Correct 99 ms 9024 KB Output is correct
44 Correct 216 ms 22536 KB Output is correct
45 Correct 36 ms 4568 KB Output is correct
46 Correct 114 ms 13812 KB Output is correct
47 Correct 294 ms 21952 KB Output is correct
48 Correct 161 ms 22468 KB Output is correct
49 Correct 154 ms 21452 KB Output is correct
50 Correct 246 ms 21348 KB Output is correct