Submission #1048646

#TimeUsernameProblemLanguageResultExecution timeMemory
1048646AndreasKRice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include "ricehub.h" int besthub(int R, int L, int X[], long long B) { int mx=0; for (int c=1;c<=L;c++){ vector <int> a; for (int r=0;r<R;r++) a.push_back(abs(X[r]-c)); sort(a.begin(),a.end()); int ttl=0; int b=B; for (int r=0;r<R;r++){ if (a[r]<=b){ b-=a[r]; ttl++; } } mx=max(mx,ttl); } return mx; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:9: error: 'vector' was not declared in this scope
    7 |         vector <int> a;
      |         ^~~~~~
ricehub.cpp:7:17: error: expected primary-expression before 'int'
    7 |         vector <int> a;
      |                 ^~~
ricehub.cpp:9:13: error: 'a' was not declared in this scope
    9 |             a.push_back(abs(X[r]-c));
      |             ^
ricehub.cpp:9:25: error: 'abs' was not declared in this scope
    9 |             a.push_back(abs(X[r]-c));
      |                         ^~~
ricehub.cpp:10:14: error: 'a' was not declared in this scope
   10 |         sort(a.begin(),a.end());
      |              ^
ricehub.cpp:10:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |         sort(a.begin(),a.end());
      |         ^~~~
      |         short
ricehub.cpp:19:12: error: 'max' was not declared in this scope; did you mean 'mx'?
   19 |         mx=max(mx,ttl);
      |            ^~~
      |            mx