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>
#define ll long long
using namespace std;
#include "ricehub.h"
ll p[100005],a[100005];
ll cost(int l,int r){
int mid = (l + r)>>1;
ll s1 = (mid - l + 1)*a[mid] - p[mid] + p[l - 1];
ll s2 = p[r] - p[mid] - (r - mid)*a[mid];
return s1+s2;
}
int besthub(int N, int R, int X[], ll B){
for (int i=0;i<N;i++){
a[i] = X[i];
p[i] = X[i];
if (i) p[i] += p[i - 1];
}
int r = 0,ans=0;
for (int i = 0; i < N; i++){
while (r + 1 < N && cost(i,r + 1) <= B) ++r;
ans=max(ans,r-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... |