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 <algorithm>
typedef long long ll;
using namespace std;
int besthub(int R, int L, int X[], long long B){
int l=0,r=0, m, nueva_m=0, MaxR=1;
ll b_gastado = 0;
while(r<R-1){
if (b_gastado<=B){
r++;
m=(l+r)/2;
b_gastado+=abs(X[r]-X[m]);
if (b_gastado<=B) MaxR=max(MaxR,r-l+1);
}else{
l++;
nueva_m=(l+r)/2;
b_gastado-=abs(X[nueva_m]-X[l-1]);
if (b_gastado<=B) MaxR=max(MaxR,r-l+1);
}
}
return MaxR;
}
# | 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... |