Submission #467490

#TimeUsernameProblemLanguageResultExecution timeMemory
467490maeolaHacker (BOI15_hac)C++17
100 / 100
463 ms43844 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int N; int A[500069]; vector<int> W[500069]; int main() { ios::sync_with_stdio(0); cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } int k = (N + 1) / 2; int b = k; int sum = 0; for (int i = 0; i < b; i++) sum += A[i]; for (int a = 0; a < N; a++) { W[a].push_back(sum); W[b].push_back(-sum); sum = sum + A[b] - A[a]; b = (b + 1) % N; } multiset<int> E; for (int i = N - k; i < N; i++) { for (int a : W[i]) if(a > 0) E.insert(a); } int mx = 0; for (int i = 0; i < N; i++) { for (int a : W[i]) if(a > 0) E.insert(a); for (int a : W[i]) if(a < 0) E.erase(E.find(-a)); mx = max(mx, *E.begin()); } cout << mx << '\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...