Submission #263341

#TimeUsernameProblemLanguageResultExecution timeMemory
263341BertedRice Hub (IOI11_ricehub)C++14
100 / 100
22 ms2560 KiB
#include "ricehub.h" #include <iostream> #define ll long long using namespace std; ll pref[100001]; int besthub(int R, int L, int X[], ll B) { int ret = 0; for (int i = 1; i <= R; i++) pref[i] = pref[i - 1] + X[i - 1]; int rg = 0; ll s = 0; for (int lf = 1; lf <= R; lf++) { rg = max(lf, rg); int md = lf + rg >> 1; s = pref[rg] - pref[md] - (pref[md - ((lf - rg + 1) & 1)] - pref[lf - 1]); while (rg <= R && s <= B) { rg++; md = lf + rg >> 1; s = pref[rg] - pref[md] - (pref[md - ((lf - rg + 1) & 1)] - pref[lf - 1]); } ret = max(ret, rg - lf); } return ret; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:17:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |   int md = lf + rg >> 1;
      |            ~~~^~~~
ricehub.cpp:21:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |    rg++; md = lf + rg >> 1;
      |               ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...