# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61020 | 2018-07-25T06:05:50 Z | nvmdava | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; vector<long long> v bool price(X[], int l,int r, long long B){ int i; long long p = 0; int m = (r + l) / 2; p = x[m] * (m - l) - v[m] + v[l] + v[r + 1] - v[m + 1] - x[m] * (r - m); if(p <= B){ return 1; } else { return 0; } } int besthub(int n, int L, int X[], long long B) { v.push_back(0); for(i = 0; i < n; i ++){ v.push_back(v.back() + X[i]); } int l = 0, r = 0, m,dif = -1,i; for(i = 0; i < n;i++){ l = i; r = n ; while(l + 1 != r){ m = (l+r) / 2; if(price(X,i,m,B)){ l = m; } else { r = m; } } dif = max(dif , r - i); } return dif; }