# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488663 | 2021-11-19T22:21:33 Z | fun_day | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; int besthub(int R, int L, vector<int> X , long long B){ int best = 0; for(int i = 0 ; i < R ; i++){ int ans = 0; long long s = 0; int l = i - 1 , r = i + 1; while(l >= 0 || r < R){ if((l < 0) || (r < R && X[r] - X[i] <= X[i] - X[l])){ s += X[r] - X[i]; r++; } else if((r >= R) || (l >= 0 && X[i] - X[l] <= X[r] - X[i])){ s += X[i] - X[l]; l--; } if(s > B) break; ans++; } best = max(best , ans); if(best == R - 1) break; } return best + 1; }