# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971693 | 2024-04-29T07:51:49 Z | batsukh2006 | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> #include "ricehub" using namespace std; #define ss second #define ff first #define endl '\n' int besthub(int r, int l, int x[], long long b){ int ans=0; for(int i=0; i<r; i++){ int sum=1; int lt=i-1,rt=i+1; while(lt>=0||rt<r){ if(lt>=0&&(abs(x[i]-x[lt])<=abs(x[i]-x[rt])||rt==r)){ if(abs(x[i]-x[lt])>b) break; sum++; b-=abs(x[i]-x[lt--]); }else{ if(abs(x[i]-x[rt])>b) break; sum++; b-=abs(x[i]-x[rt++]); } } ans=max(ans,sum); } return ans; }