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;
typedef long long int ll;
ll r,l,b;
ll qs[100010]={};
ll get_dist(ll st,ll ed)
{
ll mid=(st+ed)>>1;
ll med=qs[mid+1]-qs[mid];
return med*((ed-st+1)&1ll)+(qs[ed+1]-qs[mid+1])-(qs[mid+1]-qs[st]);
}
ll hi,low,av;
bool test_b(ll k)
{
for(ll i=0;i<=r-k;i++)
{
if(get_dist(i,i+k-1)<=b) return true;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
r=(ll)R;
l=(ll)L;
b=B;
for(int i=0;i<r;i++)
{
qs[i+1]=qs[i]+(ll)X[i];
}
hi=r;
low=1;
while(hi>low)
{
av=(hi+low+1)>>1;
if(test_b(av)) low=av;
else hi=av-1;
}
return (int)hi;
}
# | 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... |