이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
const int MAXN = 200000;
vector <long long> pre;
long long cal(int l, int r, int X[]) {
  int p = l + r >> 1;
  long long dis = 0;
  dis += ((long long) X[p] * (p-l+1) - (pre[p] - pre[l-1]));
  dis += (pre[r] - pre[p]) - (long long) X[p] * (r-p);
  return dis;
}
int besthub(int R, int L, int X[], long long B) {
  pre.resize(R);
  pre[0] = X[0];
  for (int i = 1; i < R; i++)
    pre[i] = pre[i-1] + X[i];
  int l = 1, r = R, mid;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    bool flag = 0;
    for (int i = 0; i+mid-1 < R; i++) {
      if (cal(i, i+mid-1, X) <= B) flag = 1;
    }
    if (flag) l = mid;
    else r = mid-1;
  }
  return l;
}
컴파일 시 표준 에러 (stderr) 메시지
ricehub.cpp: In function 'long long int cal(int, int, int*)':
ricehub.cpp:13:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |   int p = l + r >> 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... |