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;
long long total = 0;
int rice = 1;
while (right < mx && left < mx) {
if (X[right] - X[left] > B || total > B) {
left++;
if (left < mx) {
int mid = left + ((right - left) / 2);
total -= X[mid] - X[left - 1];
rice--;
}
} else {
right++;
if (rice > res) {
res = rice;
}
if (right < mx) {
int mid = left + ((right - left) / 2);
total += X[right] - X[mid];
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... |