#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |