# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639732 | bonk | Rice Hub (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 <bits/stdc++.h>
#include <ricehub.h>
using namespace std;
using ll = long long;
ll besthub(ll r, ll l, ll x[], ll b){
ll ans = 0;
for(ll i = 0; i < r; i++){
ll cur = 0;
for(ll j = i; j < r; j++){
cur += x[j];
ll mid = cur/(j - i + 1);
ll cost = 0;
for(ll k = i; k <= j; k++){
cost += abs(x[k] - mid);
}
if(cost <= b) ans = max(ans, j - i + 1LL);
}
}
return ans;
}