Submission #939275

# Submission time Handle Problem Language Result Execution time Memory
939275 2024-03-06T08:03:30 Z Amirreza_Fakhri Hacker (BOI15_hac) C++17
20 / 100
4 ms 604 KB
// In the name of the God
#include <bits/stdc++.h>
#define ll long long
// #define int long long
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pii pair <int, int>
#define smin(x, y) (x) = min((x), (y))
#define smax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(), (x).end()
using namespace std;

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

const int inf = 1e9+7;
const int mod = 998244353;
const int maxn = 3e2+5;

int n, v[maxn], ps[maxn];
bool mark[maxn];

int inc(int i) {
    return (i+1)%n;
}

int dec(int i) {
    return (i-1+n)%n;
}

int g(int i, int x) {
    if (i+x < n) {
        return ps[i+x]-ps[i];
    }
    int j = (i+x)%n;
    return ps[n-1]-ps[i]+ps[j];
}

int p(int i, int x) {
    i = (i-x-1+n*2)%n;
    return g(i, x);
}

int f(int i, int j) {
    int l1, l2;
    if (i < j) l1 = j-i-1, l2 = n-2-(j-i-1);
    else l1 = n-2-(i-j-1), l2 = i-j-1;
    int res1 = v[i]+g(i, (l1+1)/2);
    if (l1&1) res1 += p(i, l2/2);
    else res1 += p(i, (l2+1)/2);

    int res2 = v[i]+p(i, (l2+1)/2);
    if (l2&1) res2 += g(i, l1/2);
    else res2 += g(i, (l1+1)/2);

    return max(res1, res2);
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        ps[i] = v[i];
        if (i) ps[i] += ps[i-1];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int res = inf;
        for (int j = 0; j < n; j++) {
            if (i != j) smin(res, f(i, j));
        }
        // cout << i << ' ' << res << '\n';
        smax(ans, res);
    }
    cout << ans << '\n';
    return 0;
}

























# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Runtime error 1 ms 348 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 4 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Runtime error 1 ms 348 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -