이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
bool ok(const vector<lol>& p,int n,lol B,int k)
{
    auto query=[&](int l,int r){
        if(l>r) return 0ll;
        return p[r]-(l?p[l-1]:0);
    };
    for(int i=0;i+k-1<n;i++)
    {
        int pos=i+k/2;
        lol chk=0;
        chk+=max(0,pos-i+1)*query(pos,pos)-query(i,pos);
        chk+=query(pos+1,i+k-1)-max(0,i+k-1-pos)*query(pos,pos);
        if(chk<=B)  return true;
    }
    return false;
}
int besthub(int R,int L,int X[],lol B)
{
    vector<lol> p(R);
    partial_sum(X,X+R,p.begin());
    int l=1,r=R,mid,ans;
    while(l<=r)
    {
        mid=l+(r-l)/2;
        if(ok(p,R,B,mid))
        {
            ans=mid;
            l=mid+1;
        }else   r=mid-1;
    }
    return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
ricehub.cpp: In function 'int besthub(int, int, int*, lol)':
ricehub.cpp:36:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     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... |