Submission #987062

#TimeUsernameProblemLanguageResultExecution timeMemory
987062aaaaaarrozRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; using ll = long long; int besthub (int R, int L, int X[], long long B) { vector<int> x(R + 5); vector<ll> pref(R + 5); for (int i = 1; i <= R; i++) x[i] = X[i - 1], pref[i] = pref[i - 1] + x[i]; auto ck = [&] (int val) { for (int l = 1, r = l + val - 1; r <= R; l++, r++) { int mid = (l + r) >> 1; ll curl = x[mid] * (mid - l) - (pref[mid - 1] - pref[l - 1]); ll curr = (pref[r] - pref[mid]) - x[mid] * (r - mid); if (curl + curr <= B) return 1; } return 0; }; int l = 1, r = R; while (l <= r) { int mid = (l + r) >> 1; if (ck(mid)) l = mid + 1; else r = mid - 1; } return r

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:26:11: error: expected ';' at end of input
   26 |   return r
      |          ~^
      |           ;
ricehub.cpp:26:10: error: expected '}' at end of input
   26 |   return r
      |          ^
ricehub.cpp:7:50: note: to match this '{'
    7 | int besthub (int R, int L, int X[], long long B) {
      |                                                  ^