#include <bits/stdc++.h>
#include "ricehub.cpp"
using namespace std;
long long besthub(long long r, long long l, long long x[], long long b) {
long long ans = 1;
for(long long i = 2; i <= r; i++) {
long long left = 1, right = i, best = r;
long long mid;
while(left <= right) {
mid = (left + right) / 2;
long long FieldSituated = (mid + i) / 2, cost = 0;
//cout << "left = " << left << ", right = " << right << ", mid = " << mid << ", FieldSituated = " << FieldSituated << ", cost = ";
for(long long j = mid; j <= i; j++) {
cost += (abs(x[j] - x[FieldSituated]));
}
//cout << cost << endl;
if(cost <= b) {
right = mid - 1;
best = mid;
}
else {
left = mid + 1;
}
}
ans = max(ans, i - best + 1);
}
return ans;
}
/*int main() {
cout << "Input the number of rice fields" << endl;
long long r;
cin >> r;
cout << "Input the maximum coordinate" << endl;
long long l;
cin >> l;
cout << "Input r numbers, denoting the rice fields" << endl;
long long x[r + 1];
for(long long i = 1; i <= r; i++) {
cin >> x[i];
}
cout << "Input the budget" << endl;
long long b;
cin >> b;
cout << besthub(r, l, x, b) << endl;
}
*/
Compilation message
ricehub.cpp:2:10: fatal error: ricehub.cpp: No such file or directory
2 | #include "ricehub.cpp"
| ^~~~~~~~~~~~~
compilation terminated.