Submission #50946

#TimeUsernameProblemLanguageResultExecution timeMemory
50946win11905Rice Hub (IOI11_ricehub)C++11
100 / 100
33 ms15996 KiB
#include "ricehub.h" #include <stdio.h> const int N = 1e5+5; long long pref[N]; int besthub(int R, int L, int X[], long long B) { for(int i = 0; i < R; ++i) pref[i+1] = pref[i] + X[i]; auto f = [&](int l, int r, int m) { long long lhs = ((pref[m] - pref[m-1]) * (m-l)) - (pref[m-1] - pref[l-1]); long long rhs = (pref[r] - pref[m]) - ((pref[m] - pref[m-1]) * (r - m)); return lhs + rhs <= B; }; int l = 1, r = R; while(l < r) { int m = (l + r + 1) >> 1; bool st = false; for(int x = 1, y = m; y <= R; x++, y++) { int z = (x + y) >> 1; st |= f(x, y, z); } if(st) l = m; else r = m - 1; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...