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>
#define vi vector<int>
#define pb push_back
#define ll long long int
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int res=0;
ll pref[R];
pref[0]=X[0];
for(int i=1;i<R;i++){
pref[i]=pref[i-1]+X[i];
}
for(ll i=0;i<R;i++){
ll b=i,e=R-1;
while(b<=e){
ll mid=(b+e)/2;
ll MID=(i+mid)/2;
ll aux=pref[mid];
aux-=pref[MID];
aux-=(mid-MID)*X[MID];
if(MID!=i){
aux+=(MID-i+1)*X[MID];
aux-=pref[MID-1];
if(i)aux+=pref[i-1];
}
if(aux<=B){
res=max(res,int(mid-i+1));
b=mid+1;
}else{
e=mid-1;
}
}
}
return res;
}
# | 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... |