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>
#include "ricehub.h"
using namespace std;
using ll = long long;
int besthub(int n, int L, int X[], ll B) {
    vector<ll> p(n);
    for (int i = 0; i < n; i++)
        p[i] = (i ? p[i - 1] : 0) + X[i];
    int mx = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            bool tr = ((i & 1) != (j & 1));
            int x = (j - i) >> 1, y = (tr ? (X[i + x] + X[i + x + 1]) >> 1 : X[i + x]);
            if ((ll)(x + 1) * y - p[i + x] + (i ? p[i - 1] : 0) + p[j] - p[i + x] - (ll)(x + tr) * y > B) break;
            mx = max(mx, j - i + 1);
        }
    }
    return mx;
}
| # | 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... |