Submission #723704

#TimeUsernameProblemLanguageResultExecution timeMemory
723704The_SamuraiHacker (BOI15_hac)C++17
0 / 100
1053 ms212 KiB
#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'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...