이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#define max(x, y) ((x) > (y) ? (x) : (y))
int besthub(int R, int L, int X[], long long B)
{
int *mid = X, *begin = X, *end = X, left = 1, right = 0, max_rice = 0;
long long cost = 0;
while (mid < X + R)
{
// If the cost on the right are too high to restore balance, move the
// left pointer first.
if (end != X + R && cost + *end - *mid > B)
cost -= *mid - *begin, left--;
while (end != X + R && right <= left && cost + *end - *mid <= B)
cost += *end - *mid, right++, end++;
max_rice = max(max_rice, left + right);
mid++;
}
return max_rice;
}
# | 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... |