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"
long long b;
long long pos[100100];
long long qs[100100];
int n;
bool work(int num) {
int x=num/2;
int hub;
long long cur;
for (int i=num;i<=n;i++) {
hub=i-x;
cur=qs[i]-qs[hub]-pos[hub]*x;
cur+=pos[hub]*(num-x)-qs[hub]+qs[i-num];
if (cur<=b) return true;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
b=B;
n=R;
for (int i=1;i<=n;i++) {
qs[i]=pos[i]=X[i-1];
qs[i]+=qs[i-1];
}
int lo=1;
int hi=R;
int mid;
while (lo<hi) {
mid=(lo+hi+1)>>1;
if (work(mid)) lo=mid;
else hi=mid-1;
}
return lo;
}
# | 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... |