Submission #800677

#TimeUsernameProblemLanguageResultExecution timeMemory
800677vjudge1Rice Hub (IOI11_ricehub)C++17
68 / 100
10 ms2112 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int P[100101]; int besthub(int R, int L, int X[], long long B) { int l = 1, r = R, res = -1; for (int i = 0; i < R; i++) P[i + 1] = P[i] + X[i]; while (l <= r) { int mid = l + r >> 1; bool ok = 0; for (int i = mid - 1, j = 0; i < R; i++) { while (j - (i - mid + 1) < i - j) j++; int median = X[j]; long long LL = P[j] - P[i - mid + 1]; long long RR = P[i + 1] - P[j]; LL = 1ll * median * (j - i + mid - 1) - LL; RR = RR - 1ll * median * (i + 1 - j); if (LL + RR <= B) ok = 1; } if (ok) { res = mid; l = mid + 1; } else { r = mid - 1; } } return res; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:12:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |                 int mid = l + r >> 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...