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;
int a[1 << 17];
int besthub(int n, int useless, int v[], long long B)
{
# define int long long
int l = 1;
int r = n;
for(int i = 1;i <= n;i++)
{
a[i] = v[i - 1];
a[i] += a[i - 1];
}
while(l < r)
{
int len = (l + r + 1) / 2;
bool ok = 0;
for(int i = len;i <= n;i++)
{
int L = i - len + 1;
int R = i;
int mid = (L + R + 1) / 2;
int f = 0;
f += 1LL * (a[mid] - a[mid - 1]) * (mid - L) - a[mid - 1] + a[L - 1];
f += a[R] - a[mid] - 1LL * (a[mid] - a[mid - 1]) * (R - mid);
if(f <= B) ok = 1;
}
if(ok) l = len;
else r = len - 1;
}
return l;
}
# | 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... |