Submission #698834

#TimeUsernameProblemLanguageResultExecution timeMemory
698834finn__Rice Hub (IOI11_ricehub)C++17
0 / 100
3 ms468 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...