This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
long long idx[100005];int n;long long qs[100005];long long b;
bool chk(int a){
long long mi=LLONG_MAX;
for(int l=1;l<=n-a+1;l++){
int r =l+a-1;int m=(l+r)/2;
mi=min(mi,(m-l+1)*idx[m]-qs[m]+qs[l-1]-(r-m)*(idx[m])+qs[r]-qs[m]);
}
return mi<=b;
}
int besthub(int R, int L, int X[], long long B){
int l=0;int r=R;n=R;b=B;
for(int i=0;i<R;i++){idx[i+1]=X[i];qs[i+1]=qs[i]+idx[i+1];}
while(l<r){
int mid = (l+r+1)/2;
if(chk(mid)){
l=mid;
}
else{
r =mid-1;
}
}
return l;
}
# | 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... |