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;
#define int long long
const int N=1e5+10;
int n, a[N], pf[N];
int calc(int l, int r){
int mid=(l+r)>>1;
return a[mid]*(mid-l+1)-(pf[mid]-pf[l-1])+(pf[r]-pf[mid])-a[mid]*(r-mid);
}
int32_t besthub(int32_t R, int32_t L, int32_t X[], int B)
{
n=R;
for (int i=1; i<=n; ++i) a[i]=X[i-1];
partial_sum(a, a+n+1, pf);
int ans=0;
for (int l=1, r=1; r<=n; ++r){
while (calc(l, r)>B) ++l;
ans=max(ans, r-l+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... |