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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int left = 0; int right = 0;
int mx = R;
int res = 0;
while (right < mx && left < mx) {
if (X[right] - X[left] > B) {
left++;
}
int mid = left + ((right - left) / 2);
int total = 0;
int rice = 1;
for (int i = left; i < mid; i++) {
total += X[mid] - X[i];
rice++;
}
for (int i = mid + 1; i < right + 1; i++) {
total += X[i] - X[mid];
rice++;
}
if (total > B) {
left++;
} else {
right++;
if (rice > res) {
res = rice;
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |