Submission #888266

#TimeUsernameProblemLanguageResultExecution timeMemory
888266beabossHacker (BOI15_hac)C++14
100 / 100
232 ms18512 KiB
// Source: https://oj.uz/problem/view/BOI15_hac // #include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<int> vi; #define FOR(i, a, b) for (int i = (a); i<b; i++) bool ckmin(int& a, int b){ return b < a ? a = b, true : false; } bool ckmax(int& a, int b){ return b > a ? a = b, true : false; } const int N = 5e5 + 10; int a[N]; int res[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; FOR(i, 0, n) cin >> a[i]; int sum = 0; FOR(i, 0, (n+1)/2) sum += a[i]; int i = 0; int j = (n+1)/2; for (;i < n;) { res[i] = sum; sum += a[j]-a[i]; i++; j = (j + 1) % n; } multiset<int> window; FOR(i, 0, (n + 1) / 2) window.insert(res[i]); int ans = 0; i = 0; j = (n+1)/2; for (;i < n;) { ans = max(ans, *window.begin()); window.erase(window.find(res[i])); window.insert(res[j]); i++; j = (j + 1) % n; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...