이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
    int ans = 0;
    vector<long long> pref(R, 0);
    for (int i = 0; i < R; i++) {
        pref[i] = i == 0 ? X[0] : (pref[i - 1] + X[i]);
    }
    for (int i = 0; i < R; i++) {
        int l = 1, r = R;
        while (l <= r) {
            int m = (l + r) >> 1;
            int left = i - m / 2 + 1;
            int right = i + (m + 1) / 2;
            bool good = false;
            if (left >= 0 && right < R) {
                long long d1 = pref[right] - pref[i] - (right - i) * 1ll * X[i];
                long long d2 = 1ll * X[i] * (i - left + 1) - pref[i] + (left == 0 ? 0 : pref[left - 1]);
                good = d1 + d2 <= B;
            }
            if (good) {
                l = m + 1;
                ans = max(ans, m);
            } else r = m - 1;
        }
    }
    return 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... |