답안 #723704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723704 2023-04-14T07:56:06 Z The_Samurai Hacker (BOI15_hac) C++17
0 / 100
1000 ms 212 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

#include "bits/stdc++.h"

using namespace std;
using ll = long long;
int INF = 2e9;


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x: a)
        cin >> x;
    auto get = [&](int i, int j, int add1, int add2) {
        vector<bool> used(n);
        int now = 0;
        bool sw1 = false, sw2 = false;
        for (int k = 0; k < n; k++) {
//            cout << '\t' << i << ' ' << j << ' ' << used[i] << ' ' << now << endl;
            if (!used[i]) now += a[i];
            used[i] = 1;
            used[j] = 1;
            if (used[(i + add1 + n) % n]) {
                if (!sw1) add1 = -add1;
                sw1 = 1;
            }

            if (used[(j + add2 + n) % n]) {
                if (!sw2) add2 = -add2;
                sw2 = 1;
            }

            i = (i + add1 + n) % n;
            j = (j + add2 + n) % n;
        }
//        cout << now << endl;
        return now;
    };
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int now1 = 2e9, now2 = 2e9;
        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;

            now1 = min(now1, max(get(i, j, 1, 1), get(i, j, -1, 1)));
            now2 = min(now2, max(get(i, j, 1, -1), get(i, j, -1, -1)));
//            cout << i << ' ' << j << ' ' << now1 << ' ' << now2 << endl;


        }
        ans = max(ans, max(now1, now2));
    }
    cout << ans;
}

int main() {
    ::srand(::time(0));
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int queries = 1;
#ifdef test_cases
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
//    cin >> queries;
#else
    //    cin >> queries;
#endif

    for (int test_case = 1; test_case <= queries; test_case++) {
        solve();
//        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1053 ms 212 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -