Submission #634648

#TimeUsernameProblemLanguageResultExecution timeMemory
634648rockoanaRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include <vector> #include "ricehub.h" using namespace std; vector<long long> s; long long cost(int st, int dr, int& X[]) { int mid = (st + dr) / 2; // X[mid + 1] - X[mid] + X[mid + 2] - X[mid]...X[dr] - X[mid]; // X[mid] - X[mid] + X[mid] - X[mid - 1] + ... + X[mid] - X[st] long long res = s[dr] - s[mid] - s[mid]; if (st != 0) { res += s[st - 1]; } if ((dr - st + 1) % 2 == 1) { res += X[mid]; } return res; } int besthub(int R, int L, int X[], long long B) { s.assign(R, 0); for (i64 i = 0; i < R; i++) { s[i] += X[i]; if (i != 0) { s[i] += s[i - 1]; } } int st = 0; int res = 0; for (int i = 0; i < R; i++) { while (cost(st, i, X) > B) { st++; } res = max(res, i - st + 1); } return res; }

Compilation message (stderr)

ricehub.cpp:8:37: error: declaration of 'X' as array of references
    8 | long long cost(int st, int dr, int& X[]) {
      |                                     ^
ricehub.cpp: In function 'long long int cost(...)':
ricehub.cpp:9:14: error: 'st' was not declared in this scope; did you mean 's'?
    9 |   int mid = (st + dr) / 2;
      |              ^~
      |              s
ricehub.cpp:9:19: error: 'dr' was not declared in this scope
    9 |   int mid = (st + dr) / 2;
      |                   ^~
ricehub.cpp:19:12: error: 'X' was not declared in this scope
   19 |     res += X[mid];
      |            ^
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:8: error: 'i64' was not declared in this scope
   27 |   for (i64 i = 0; i < R; i++) {
      |        ^~~
ricehub.cpp:27:19: error: 'i' was not declared in this scope
   27 |   for (i64 i = 0; i < R; i++) {
      |                   ^