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;
const int MAXR = 111111;
typedef long long lld;
lld psum[MAXR];
lld interval( int i, int j ) {
// [i, j]
int m = (i + j)/2, x = psum[m] - psum[m-1];
return ( 2*m - i - j ) * 1LL * x - psum[m-1] + psum[i-1] + psum[j] - psum[m];
}
int besthub(int R, int L, int X[], long long B)
{
for(int i=1; i<=R; i++) psum[i] = psum[i-1] + X[i-1];
int j = 1, ret = 0;
for(int i=1; i<=R; i++)
while( j<=R && interval(i, j) <= B ) ret = max( ret, j-i+1), j++;
return ret;
}
# | 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... |