#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n;
cin >> n;
const int SZ = (n + 1) / 2;
vi a(2 * n);
for(int i = 0; i < n; i++){
cin >> a[i];
a[n + i] = a[i];
}
for(int i = 1; i < 2 * n; i++){
a[i] += a[i - 1];
}
auto sum = [&](int l, int r) -> int {
if(!l) return a[r];
return a[r] - a[l - 1];
};
multiset<int> s;
vi ans(2 * n, LLONG_MAX);
for(int i = 0; i < 2 * n; i++){
if(i + SZ - 1 < 2 * n) s.emplace(sum(i, i + SZ - 1));
if(i > SZ) s.erase(s.find(sum(i - SZ, i - 1)));
ans[i] = min(ans[i], *s.begin());
}
int res = 0;
for(int i = 0; i < n; i++){
res = max(res, min(ans[i], ans[i + n]));
}
cout << res << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
660 KB |
Output is correct |
4 |
Correct |
31 ms |
4788 KB |
Output is correct |
5 |
Correct |
88 ms |
11272 KB |
Output is correct |
6 |
Correct |
124 ms |
13904 KB |
Output is correct |
7 |
Correct |
133 ms |
16676 KB |
Output is correct |
8 |
Correct |
279 ms |
27736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |