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;
using ll = long long;
int besthub(int n, int l, int x[], ll b) {
vector<ll> v(n);
for (int i=0; i<n; i++) v[i]=x[i]+(i?v[i-1]:0);
auto get = [&](int s, int e) { return v[e]-(s?v[s-1]:0); };
int mx=0;
for (int i=0; i<n; i++) {
int s=i, e=n-1;
while (s<e) {
int m=(s+e+1)/2;
if (get((s+m+1)/2, m)-get(s, (s+m)/2)>b) e=m-1;
else s=m;
}
mx=max(mx, s-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... |