Submission #1118642

#TimeUsernameProblemLanguageResultExecution timeMemory
1118642orcslopHacker (BOI15_hac)C++17
0 / 100
2 ms4448 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5 + 5; int n; int v[N << 1]; int a[N << 1], r[N << 1]; multiset<int> ms; int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 0; i < n; i++){ cin >> v[i]; v[i + n] = v[i]; } for(int i = 1; i < 2 * n; i++){ v[i] += v[i - 1]; } auto get_sum = [&](int x) -> int{ return v[x + (n - 1) / 2] - (x ? v[x - 1] : 0); }; for(int i = 0; i < n; i++){ a[i] = r[i + (n + 1) / 2] = get_sum(i); } int ans = 0; for(int i = 0; i < 2 * n; i++){ ms.insert(a[i]); ms.extract(r[i]); ans = max(ans, *ms.begin()); // cout << a[i] << ' ' << r[i] << '\n'; } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...