# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364905 | hoaphat1 | Rice Hub (IOI11_ricehub) | C++17 | 21 ms | 2668 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>
using namespace std;
int besthub(int n, int lim, int a[], long long b) {
int l = 1, r = n;
vector<long long> t(n);
for (int i = 0; i < n; i++) {
t[i] = a[i];
if (i) t[i] += t[i-1];
}
auto getv = [&](int l, int r) {
if (!l) return t[r];
return t[r] - t[l-1];
};
auto test = [&](int num) {
for (int i = 0; i + num <= n; i++) {
auto get = [&](int n) {
return -getv(i, i + n - 1) + getv(i + n, i + num - 1) - 1ll * a[i + n - 1] * (num - n - n);
};
if (min(get(num / 2), get((num + 1) / 2)) <= b) return true;
}
return false;
};
while (l <= r) {
int mid = l + r >> 1;
if (test(mid)) l = mid + 1;
else r = mid - 1;
}
return r;
}
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... |