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>
using namespace std;
typedef long long ll;
ll ab(ll x){
return max(x, -x);
}
int besthub(int n, int L, int X[], ll B){
int l = 1, r = n + 1;
int k;
bool ok;
int med;
ll sum = 0;
while(l + 1 < r){
k = (l + r)/2;
ok = false;
for(int i = 0;i <= n-k;i ++ ){
med = (i + k - 1) / 2;
sum = 0;
for(int j = 0;j < k;j ++ ){
sum += ab(X[i + j] - X[med]);
}
if(sum <= B)
ok = true;
}
if(ok)
l = k;
else
r = k;
}
return l;
}
# | 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... |