This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int s[2 * N], a[2 * N], n;
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 = 2e9;
for(int i = n + 1 - len + 1; i <= n + 1; ++i) ans = min(ans, s[i + len - 1] - s[i - 1]);
cout << ans;
}
# | 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... |