# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582434 | Mystic03 | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <iostream>
#define int long long
using namespace std;
int32_t besthub(int32_t n, int32_t L, int32_t X[], long long B){
int from = 0;
int to = 0;
long long cost = 0;
int res = 1;
while (true) {
int currRange = to - from + 1;
to++;
if (to >= n) break;
int newDist = X[to] - X[to - 1];
cost += (long long)currRange * newDist;
while (cost > B) {
cost -= X[to] - X[from];
from++;
}
res = max(res, to - from + 1);
}
return res;
}
int32_t main() {
int a, b, c;
cin >> a >> b >> c;
vector<int32_t> v(a);
for (auto& x : v) cin >> x;
cout << besthub(a, b, v.data(), c) << endl;
system("PAUSE");
}