이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define sz(v) (int)v.size()
#define ps(y) cout << fixed << setprecision(y)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define trav(x, v) for(auto &x: v)
#define w(t) int t; cin >> t; while(t--)
#define rep0(i, n) for(int i = 0; i < n; i++)
#define rrep0(i, n) for(int i = n - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define rrep1(i, n) for(int i = n; i > 0; i--)
#define inp(arr, n) rep0(i, n) cin >> arr[i];
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<ll, ll> mii;
typedef map<char, ll> mci;
typedef priority_queue<ll> pq_mx;
typedef priority_queue<ll, vi, greater<>> pq_mn;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> pbds;
/*
* find_by_order(i) -> returns an iterator to the element at ith position (0 based)
* order_of_key(i) -> returns the position of element i (0 based)
*/
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void fio() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}
ll n, a[N], pre[N], sub[N];
int main() {
fio();
cin >> n;
inp(a, n)
rep(x, n, 2 * n - 1) a[x] = a[x - n];
rep1(x, 2 * n) pre[x] = pre[x - 1] + a[x - 1];
trav(x, sub) x = 1e9;
ll k = (n + 1) / 2;
multiset<ll> st;
rep0(x, 2 * n) {
if (x + k - 1 < 2 * n) st.insert(pre[x + k] - pre[x]);
if (x > k) st.erase(st.find(pre[x] - pre[x - k]));
sub[x % n] = min(sub[x % n], *st.begin());
}
ll res = 0;
rep0(x, n) res = max(res, sub[x]);
cout << res;
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... |