이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of God
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
const int N = 1e6 + 5;
int n, v[N], s[N];
void solve() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> v[i];
v[i + n] = v[i];
}
int ans = 0;
multiset<int> st;
for (int i = 0; i < (n + 1) / 2; i++)
s[(n + 1) / 2 - 1] += v[i];
for (int i = (n + 1) / 2; i < 2 * n; i++) {
s[i] = s[i - 1] - v[i - (n + 1) / 2] + v[i];
}
for (int i = (n + 1) / 2 - 1; i <= 2 * ((n + 1) / 2 - 1); i++) {
st.insert(s[i]);
}
ans = *st.begin();
for (int i = (n + 1) / 2; i + (n + 1) / 2 - 1 < 2 * n; i++) {
st.erase(st.find(s[i - 1]));
st.insert(s[i + (n + 1) / 2 - 1]);
ans = max(ans, *st.begin());
}
cout << ans << '\n';
}
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |