Submission #60997

#TimeUsernameProblemLanguageResultExecution timeMemory
60997nvmdavaRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include "ricehub.h" bool price(int X[], int l,int r, long long B){ int i; long long p = 0; int m = (r + l) / 2; for(i = l; i <m ; i++){ p +=(long long)X[m] - X[l]; } for(i = m + 1; i <=r ; i++){ p +=(long long)X[i] - X[m]; } if(p <= B){ return 1; } else { return 0; } } int besthub(int n, int L, int X[], long long B) { int l = 0 r = 0, dif = -1; while(r != n){ if(price(X[] ,l, r, B)){ dif = max(dif, r - l + 1); r++; } else { l++; } } return dif; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:23:12: error: expected ',' or ';' before 'r'
  int l = 0 r = 0, dif = -1;
            ^
ricehub.cpp:24:8: error: 'r' was not declared in this scope
  while(r != n){
        ^
ricehub.cpp:25:14: error: expected primary-expression before ']' token
   if(price(X[] ,l, r, B)){
              ^
ricehub.cpp:26:4: error: 'dif' was not declared in this scope
    dif = max(dif, r - l + 1);
    ^~~
ricehub.cpp:26:10: error: 'max' was not declared in this scope
    dif = max(dif, r - l + 1);
          ^~~
ricehub.cpp:32:9: error: 'dif' was not declared in this scope
  return dif;
         ^~~