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>
typedef long long ll;
ll get(int x, int y, int* a, ll* b) {
return ((((x + y) >> 1) - x + 1) - (y - ((x + y) >> 1))) * a[(x + y) >> 1] - (b[(x + y) >> 1] - (x ? b[x - 1] : 0)) + (b[y] - b[(x + y) >> 1]);
}
int besthub(int r, int l, int* x, ll b) {
ll a[r], sum;
a[0] = x[0];
for (int i = 1; i < r; i++) a[i] = a[i - 1] + x[i];
int i = 0, ans = 0;
for (int j = 0; j < r; j++) {
sum = get(i, j, x, a);
while (sum > b) i++, sum = get(i, j, x, a);
ans = std::max(ans, j - i + 1);
}
return ans;
}
# | 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... |