# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
460477 | 2021-08-09T07:11:45 Z | fuad27 | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; int besthub(int r, int l, int x[], long long b) { int MAX = 0; for(int i = 1;i<r;i++) { int c = 0; long long cost = 0; int p1 = 0, p2 = MAX-1 while(p1 < r and p2 <= r) { if(cost <= b) { c = max(p2 - p1, c); p2++; if(p2 <= r) cost+=abs(x[p2-1] - x[i]); } else { cost-=abs(x[p1]-x[i]); p1++; } } MAX = max(c, MAX); } return MAX; }