Submission #31581

#TimeUsernameProblemLanguageResultExecution timeMemory
31581minkankHacker (BOI15_hac)C++14
100 / 100
703 ms25484 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int s[2 * N], a[2 * N], n, m[2 * N]; multiset<int> st; int main() { cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i], a[i + n] = a[i]; for(int i = 1; i <= 2 * n; ++i) s[i] = s[i - 1] + a[i]; int len = (n + 1) / 2, ans = 0; for(int i = 1; i <= 2 * n - len + 1; ++i) m[i] = s[i + len - 1] - s[i - 1]; for(int i = 1; i <= 2 * n - len + 1; ++i) { if(i > len) { multiset<int>::iterator it = st.find(m[i - len]); st.erase(it); } st.insert(m[i]); if(i >= len) ans = max(ans, *st.begin()); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...