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<bits/stdc++.h>
#include "ricehub.h"
#define fi first
#define se second
using namespace std;
const int NN=1e5;
long long t[NN+10];
void move_med(int l,int r,int &m,long long &w)
{
if(m==(l+r)/2)
return;
w+=(t[m+1]-t[m])*(m-l+1);
w-=(t[m+1]-t[m])*(r-m);
m++;
return;
}
int besthub(int R,int L,int X[],long long B)
{
for(int i=0;i<R;i++)
t[i]=X[i];
int ans=0;
int l=0,r=0,m=0;
long long w=0;
while(l<R)
{
if(w>B)
{
w-=X[m]-X[l];
l++;
move_med(l,r,m,w);
}
else
{
ans=max(ans,r-l+1);
r++;
if(r>=R)
break;
w+=X[r]-X[m];
move_med(l,r,m,w);
}
}
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... |