#include <bits/stdc++.h>
// mrrrow meeow :3
// go play vivid/stasis now! it's free on steam
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = [] {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
return 0;
}();
int px[100001];
int func(int start, int len) {
return (px[start + len] - px[start + (len + 1) / 2]) - (px[start + len / 2] - px[start]);
};
int besthub(int rl, int _, int x[], long long b) {
fo(i, 0, rl) px[i + 1] = px[i] + x[i];
int res = 0;
fo(i, 1, rl + 1) {
int l = 0, r = rl - i;
while (l < r) {
int mid = (l + r) / 2;
if (mid + 1 + i <= rl && func(mid, i) > func(mid + 1, i)) l = mid + 1;
else r = mid;
}
if (func(l, i) <= b) res = max(res, i);
}
return res;
}
# | 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... |