Submission #655504

#TimeUsernameProblemLanguageResultExecution timeMemory
655504PanTkdRice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <iostream> #include <cmath> typedef long long ll; using namespace std; bool ok (ll x, ll R,ll L,ll X[],ll B){ ll i = x; ll cost = 0; ll med = ((i)/2); for(ll j = 0;j<i;j++){ cost += abs(X[med]-X[j]); } if(cost<=B){ return 1;} for(ll j = 1;j<=R-i;j++){ med++; cost += (i/2-(i-1)/2)*(X[med]-X[med-1]); cost += abs(X[med]-X[j+i-1]); cost -= abs(X[med-1]-X[j-1]); if(cost<=B){return 1;} } return 0; } int besthub(int R, int L, int X[], long long B) { ll l = 1 , ll r = R; ll ans = 1; while(l<=r){ ll m = (l+r)>>1; if (ok(m,R,L,X,B)) { ans = max (ans, m); l = m; } else{ r = m - 1; } } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:17: error: expected initializer before 'r'
   27 |   ll l = 1 , ll r = R;
      |                 ^
ricehub.cpp:29:12: error: 'r' was not declared in this scope
   29 |   while(l<=r){
      |            ^
ricehub.cpp:32:18: error: cannot convert 'int*' to 'll*' {aka 'long long int*'}
   32 |     if (ok(m,R,L,X,B))
      |                  ^
      |                  |
      |                  int*
ricehub.cpp:8:29: note:   initializing argument 4 of 'bool ok(ll, ll, ll, ll*, ll)'
    8 | bool ok (ll x, ll R,ll L,ll X[],ll B){
      |                          ~~~^~~