//#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
long long ans = 0;
int l = 0, r = R;
long long pre[R+1];
pre[0] = 0;
for(int i =0; i < R; i++) pre[i+1]=pre[i]+X[i];
while(l<=r) {
int m = (l+r)/2;
bool t = 0;
for(int i = 0; i < R ; i++) {
if(i+m<=R) {
long long cnt = 0;
int k = (m+1)/2;
cnt+=k*X[i+k] -pre[i+k] + pre[i];
cnt+=pre[i+2*k]-pre[k] - k*X[i+k];
if(cnt<=B) {
t=1;
break;
}
}
else break;
}
if(t) l = m+1;
else r= m-1;
}
return r;
}
# | 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... |