Submission #1111781

#TimeUsernameProblemLanguageResultExecution timeMemory
1111781Kirill22Hacker (BOI15_hac)C++17
100 / 100
317 ms22272 KiB
#include "bits/stdc++.h" using namespace std; void solve() { int n; cin >> n; vector<int> a(2 * n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i + n] = a[i]; } vector<int> pref(a.size() + 1); for (int i = 1; i < (int) pref.size(); i++) { pref[i] = pref[i - 1] + a[i - 1]; } int ans = 0, sz = n / 2, uk = 0; multiset<int> st; for (int i = 0; i < n; i++) { while (uk + sz - 1 < i + n) { st.insert({pref[uk + sz] - pref[uk]}); uk++; } st.erase(st.find(pref[i + sz] - pref[i])); ans = max(ans, pref[n] - *st.rbegin()); } cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...