Submission #987062

# Submission time Handle Problem Language Result Execution time Memory
987062 2024-05-21T19:09:59 Z aaaaaarroz Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#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

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) {
      |                                                  ^