| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1220628 | hmms127 | Rice Hub (IOI11_ricehub) | C++20 | 0 ms | 0 KiB | 
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
int besthub (int n, int L, int arr[], ll B) {
   int r=0,idx=0,dist=0,ans=0;
   for(int i=0;i<n;i++){
       dist+=a[i]-a[r];
       while(r<i&&(r-idx+1)<(i-r+1)){
           dist-=(i+idx-r*2-1)*(a[r+1]-a[r]);
           r++;
       }
       while(dist>B){
           dist-=a[r]-a[idx];
           idx++;
            while(r<i&&(r-idx+1)<(i-r+1)){
           dist-=(i+idx-r*2-1)*(a[r+1]-a[r]);
           r++;
            }
       }
       ans=max(ans,r-idx+1);
   }
   return ans;
}
