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;
#define ll long long
const int N = 1e5 + 5;
ll a[N];
int b;
int besthub(int n, int L, int X[], ll B){
ll ans = 0;
ll pref[N + 1];
pref[0] = 0;
for(int i = 0; i < n; ++i)
pref[i + 1] = pref[i] + X[i];
if(B >= pref[n])
return n;
ll l = 1, r = 1;
while(r <= n)
{
ll mid = (l + r) >> 1;
if(ans == n)
return n;
if( ((X[mid - 1] * (mid - l)) - (pref[mid - 1] - pref[l - 1]) + ((pref[r] - pref[mid]) - (X[mid - 1] * (r - mid)))) <= B)
ans = max(ans,r-l+1);
else
++l;
++r;
}
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... |