| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 502840 | wind_reaper | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KiB | 
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"
using namespace std;
int besthub(int R, int L, int X[], int64_t B){
	int64_t temp = 0; int ans = 0;
	
	for(int l = 0, r = 0; l < R; l++){
		while(r + 1 < R && temp + X[r + 1] - X[(l + r + 1) / 2] <= B){
			temp += X[r + 1] - X[(l + r + 1)/2];
			r++;
			ans = max(ans, r - l + 1);
		}
		temp += X[l] - X[(r + l + 1)/2];
	}
	
	return ans;
}
