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;
typedef long long ll;
int besthub(int R, int L, int* X, ll B){
ll sum, a[R];
a[0] = X[0];
for(int i = 1; i < R; ++i)a[i] = a[i-1]+X[i];
int x = 0, ans = 0;
for(int j = 0; j < R; ++j){
ll mid = (x+j)>>1;
sum = ((mid-x+1) - (j-mid))*X[mid]-(a[mid]-(x?a[x-1]:0))+(a[j]-a[mid]);
while(sum > B){
++x;
mid = (x+j)>>1;
sum = ((mid-x+1) - (j-mid))*X[mid]-(a[mid]-(x?a[x-1]:0))+(a[j]-a[mid]);
}
ans = max(ans, j-x+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... |