# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443037 | hibye1217 | Rice Hub (IOI11_ricehub) | C++17 | 16 ms | 2508 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.
#ifndef NOTSUBMIT
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#endif // NOTSUBMIT
typedef long long ll;
ll sum[100020];
int besthub(int R, int L, int X[], ll B){
for (int i = 1; i <= R; i++){ sum[i] = sum[i-1] + X[i-1]; }
int st = 1, ed = R, ans = 1;
while (st <= ed){
int mid = st + ed >> 1;
ll res = 1e18;
for (int e = mid; e <= R; e++){
int s = e-mid+1;
int m = s+e >> 1;
int lc = m-s+1, rc = e-m;
ll ls = lc*X[m-1] - (sum[m]-sum[s-1]);
ll rs = (sum[e]-sum[m]) - rc*X[m-1];
//cout << "RS " << sum[e] << ' ' << sum[m] << ' ' << rc << ' ' << X[m] << endl;
//cout << "MID " << s << ' ' << m << ' ' << e << " = " << ls<<' '<<rs << endl;
res = min(res, ls+rs);
}
if (res <= B){ st = mid+1; ans = mid; }
else{ ed = mid-1; }
}
return ans;
}
Compilation message (stderr)
# | 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... |