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>
int besthub(int R, int L, int X[], long long B)
{
int optimalGain=0;
int m, l, r;
l = r = m = 0;
long long spent = 0;
int localGain = 0;
while(1) {
if(r!=(R-1))r++;
else break;
m = (r+l+1)/2;
spent+= X[r]-X[m];
if(spent>B) {
optimalGain = std::max(optimalGain, localGain);
localGain++;
while(spent>B) {
spent+= X[l]-X[m];
l++;
m = (r+l+1)/2;
localGain--;
}
continue;
}
localGain++;
}
return optimalGain ;
}
# | 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... |