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;
using ll=long long;
using db=long double;
template<class T> using V=vector<T>;
using vi = V<int>;
using vl = V<ll>;
using pi = pair<int,int>;
#define f first
#define s second
#define sz(x) (int)((x).size())
int besthub(int R, int L, int X[], ll B) {
vl pre(R+1);
vl x(R);
for (int i = 0; i < R; i++) pre[i+1] = pre[i] + (x[i]=X[i]);
int best = 1;
int l = 0, r = 1;
while (l < R) {
r = max(l+1, r);
while (r <= R) {
int m = (l+r)/2;
ll lo = pre[m]-pre[l];
ll up = pre[r]-pre[m];
lo = x[m]*(m-l) - lo;
up -= x[m]*(r-m);
if (lo + up <= B) {
best = max(best, r-l);
r += 1;
} else break;
}
l++;
}
return best;
}
# | 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... |