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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100100;
int n;
ll x[N];
ll qs[N];
int besthub(int NN, int L, int X[], ll B) {
n = NN;
for (int i = 1;i <= n;i++) {
x[i] = X[i - 1];
qs[i] = qs[i - 1] + x[i];
}
int ans = 0;
for (int i = 1, j = 1;i <= n;i++) {
while (j < i) {
int med = (i + j) / 2;
ll suml = qs[med] - qs[j - 1];
ll sumr = qs[i] - qs[med];
if ((x[med] * (med - j + 1) - suml) + (sumr - x[med] * (i - med)) > B) j++;
else break;
}
ans = max(ans, i - j + 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... |