제출 #1126726

#제출 시각아이디문제언어결과실행 시간메모리
1126726ssitaramHacker (BOI15_hac)C++20
100 / 100
376 ms13924 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int len = (n + 1) / 2; vector<int> a(n); for (int& i : a) cin >> i; partial_sum(a.begin(), a.end(), a.begin()); auto at = [&](int i) -> int { i = (i % n + n) % n; int e = (i + len - 1) % n; if (i <= e) { return a[e] - (i == 0 ? 0 : a[i - 1]); } return a[n - 1] - a[i - 1] + a[e]; }; multiset<int> ms; for (int i = -len; i < 0; ++i) ms.insert(at(i)); int ans = -1; for (int i = 0; i < n; ++i) { ms.erase(ms.find(at(i - len))); ms.insert(at(i)); ans = max(ans, *ms.begin()); } 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...