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 "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
long long S(int X[], int h, int l, int r)
{
long long sum = 0;
for(int i = l; i<=r; i++)
sum = sum + abs(h-X[i]);
return sum;
}
int besthub(int R, int L, int X[], long long B)
{
int res = 0;
int r = R;
for(int it = 0; it<30; it++)
{
int k = r/2;
bool flag = false;
for(int i = 0; i<=R-k; i++)
{
int curr = S(X, X[(2*i+k-1)/2], i, i+k-1);
if(curr<=B)
flag = true;
}
if(flag)
{
res = max(res, k);
r++;
}
else
{
r = k;
}
}
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... |