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
#define pb push_back		 
#define F first																 
#define S second 															 
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1e5+5;
ll sum[mxn];
ll f(int ind){
	if(ind<0){
		return 0;
	}
	return sum[ind];
}
ll cal(int l,int r,int arr[]){
	int m=(l+r)/2;
	ll k=0;
	k+=arr[m]*(m-l+1)-(sum[m]-f(l-1));
	k+=sum[r]-f(m-1)-arr[m]*(r-m+1);
	return k;
}
int besthub(int n, int dis, int arr[], long long k)
{
	sum[0]=arr[0];
	for(int i=1;i<n;i++){
		sum[i]=sum[i-1]+arr[i];
	}
	int l=0;
	int ans=0;
	for(int i=0;i<n;i++){
		while(cal(l,i,arr)>k){
			l++;
		}
		ans=max(ans,i-l+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... |