# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70620 | doowey | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
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 "grader.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;
int k;
bool ok;
int med;
ll sum = 0;
while(l < r){
k = (l + r)/2;
cout << k << " ";
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 - 1;
}
return l;
}