Submission #939268

# Submission time Handle Problem Language Result Execution time Memory
939268 2024-03-06T07:55:40 Z Amirreza_Fakhri Hacker (BOI15_hac) C++17
20 / 100
1000 ms 460 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];
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) {
    int res = 0;
    for (int j = 1; j <= x; j++) {
        i = inc(i);
        res += v[i];
    }
    return res;
}

int p(int i, int x) {
    int res = 0;
    for (int j = 1; j <= x; j++) {
        i = dec(i);
        res += v[i];
    }
    return res;
}

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];
    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 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 460 KB Output is correct
7 Correct 115 ms 432 KB Output is correct
8 Correct 115 ms 436 KB Output is correct
9 Correct 116 ms 440 KB Output is correct
10 Correct 115 ms 344 KB Output is correct
11 Correct 115 ms 344 KB Output is correct
12 Correct 115 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 115 ms 440 KB Output is correct
17 Correct 114 ms 344 KB Output is correct
18 Correct 115 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 460 KB Output is correct
7 Correct 115 ms 432 KB Output is correct
8 Correct 115 ms 436 KB Output is correct
9 Correct 116 ms 440 KB Output is correct
10 Correct 115 ms 344 KB Output is correct
11 Correct 115 ms 344 KB Output is correct
12 Correct 115 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 115 ms 440 KB Output is correct
17 Correct 114 ms 344 KB Output is correct
18 Correct 115 ms 344 KB Output is correct
19 Execution timed out 1036 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 377 ms 444 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 460 KB Output is correct
7 Correct 115 ms 432 KB Output is correct
8 Correct 115 ms 436 KB Output is correct
9 Correct 116 ms 440 KB Output is correct
10 Correct 115 ms 344 KB Output is correct
11 Correct 115 ms 344 KB Output is correct
12 Correct 115 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 115 ms 440 KB Output is correct
17 Correct 114 ms 344 KB Output is correct
18 Correct 115 ms 344 KB Output is correct
19 Execution timed out 1036 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -