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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef __local__
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
vector<int> lis(n);
for (int i = 0; i < n; i++)
cin >> lis[i];
vector<int> sussies(n, inf);
int k = (n + 1) / 2;
lis.insert(lis.end(), lis.begin(), lis.end());
vector<long long> sm(lis.size()+1);
for(int i = 1; i <= lis.size(); ++i) sm[i] = sm[i-1] + lis[i-1];
for (int i = 0; i < n; i++) {
int cur = sm[i+k] - sm[i];
// for (int j = 0; j < k; j++)
// cur += lis[i+j];
for (int j = 0; j < k; j++)
sussies[(i+j)%n] = min(cur, sussies[(i+j)%n]);
}
cout << *max_element(sussies.begin(), sussies.end());
return 0;
}
Compilation message (stderr)
hac.cpp: In function 'int main()':
hac.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 1; i <= lis.size(); ++i) sm[i] = sm[i-1] + lis[i-1];
| ~~^~~~~~~~~~~~~
# | 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... |