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 N = 1e5 + 1;
long long qs[N];
bool solve(int mid,int n,long long t) {
long long l,r;
for (int i=(mid+1)/2;i+mid/2<=n;i++) {
if (mid%2) l = qs[i-1] - qs[max(0, i-mid/2-1)];
else l = qs[i] - qs[max(0, i-mid/2)];
r = qs[i+mid/2] - qs[i];
if (r - l <= t) return true;
}
return false;
}
int besthub(int n,int m,int x[],long long t) {
for (int i=0;i<n;i++) qs[i+1] = qs[i] + x[i];
int l = 1 , r = n , ans = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (solve(mid, n, t)) l = mid + 1 , ans = mid;
else r = mid - 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... |