Submission #284510

#TimeUsernameProblemLanguageResultExecution timeMemory
284510BasilhijazRice Hub (IOI11_ricehub)C++17
0 / 100
4 ms640 KiB
#include "ricehub.h" using namespace std; typedef long long ll; int besthub(int R, int L, int X[], long long B) { ll pre[R + 1]; pre[0] = 0; for(int i = 0; i < R; i++){ pre[i + 1] = X[i] + pre[i]; } int lo = 0; int hi = R; while(lo < hi){ ll mid = (lo + hi + 1)/2; bool can = 0; for(int i = 0; i + mid - 1 < R; i++){ ll sum = 0; ll nos = (i + i + mid - 1)/2; sum += X[nos]*mid - (pre[nos] - pre[i]); sum += (pre[i + i + mid - 1] - pre[nos]) - X[nos]*mid; if(sum <= B){ can = 1; break; } } if(can){ lo = mid; } else{ hi = mid - 1; } } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...