답안 #723548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723548 2023-04-14T04:54:38 Z dxz05 Hacker (BOI15_hac) C++17
40 / 100
1000 ms 852 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define MP make_pair
const int N = 100500;

int n;
int a[N], p[N];

int get_sum(int l, int r){
    if (l <= r){
        return p[r] - (l == 0 ? 0 : p[l - 1]);
    } else {
        return p[r] + (p[n - 1] - p[l - 1]);
    }
}

void solve(){
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> a[i];
        p[i] = a[i] + (i > 0 ? p[i - 1] : 0);
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        int mx = 0;
        for (int l = i + 1; l < n; l++){
            int r = (l + n / 2 - 1) % n;
            if (l <= r && l <= i && i <= r) continue;
            if (l > r && (l <= i || i <= r)) continue;
            mx = max(mx, get_sum(l, r));
        }

        for (int l = 0; l < i; l++){
            int r = (l + n / 2 - 1) % n;
            if (l <= r && l <= i && i <= r) continue;
            if (l > r && (l <= i || i <= r)) continue;
            mx = max(mx, get_sum(l, r));
        }

        ans = max(ans, get_sum(0, n - 1) - mx);
    }

    cout << ans << endl;

}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 45 ms 340 KB Output is correct
23 Correct 116 ms 352 KB Output is correct
24 Correct 43 ms 340 KB Output is correct
25 Correct 118 ms 352 KB Output is correct
26 Correct 118 ms 352 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 116 ms 352 KB Output is correct
31 Correct 121 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 120 ms 356 KB Output is correct
4 Execution timed out 1077 ms 852 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 45 ms 340 KB Output is correct
23 Correct 116 ms 352 KB Output is correct
24 Correct 43 ms 340 KB Output is correct
25 Correct 118 ms 352 KB Output is correct
26 Correct 118 ms 352 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 116 ms 352 KB Output is correct
31 Correct 121 ms 356 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 120 ms 356 KB Output is correct
35 Execution timed out 1077 ms 852 KB Time limit exceeded
36 Halted 0 ms 0 KB -