Submission #600223

#TimeUsernameProblemLanguageResultExecution timeMemory
600223_Avocado_Rice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
//#include <bits/stdc++.h> #include "ricehub.h" //#define int int64_t using namespace std; int bsearch(int n, int len, vector<int>&fred, vector<int>&prefix, int budget){ int l = -1; int r = n+1; while(r-l > 1){ int m = (r+l)/2; int ans = 1e9; int mid = m/2+1; for(int i = m; i<=n; ++i){ int hub = fred[mid]; int one = ((m/2) * hub)-(prefix[mid-1]-prefix[i-m]); int two = (prefix[i]-prefix[mid-(1-m%2)]) - ((m/2)*hub); ++mid; ans = min(ans, one+two); } if(ans <= budget) l = m; else r = m; } return l; } int besthub(int n, int len, vector<int>&x, int budget){ vector<int>prefix(n+1); for(int i = 1; i<=n; ++i){ prefix[i] = prefix[i-1] + x[i-1]; } vector<int>fred; fred.push_back(0); for(auto u: x) fred.push_back(u); return bsearch(n, len, fred, prefix, budget); }

Compilation message (stderr)

ricehub.cpp:6:29: error: 'vector' has not been declared
    6 | int bsearch(int n, int len, vector<int>&fred, vector<int>&prefix, int budget){
      |                             ^~~~~~
ricehub.cpp:6:35: error: expected ',' or '...' before '<' token
    6 | int bsearch(int n, int len, vector<int>&fred, vector<int>&prefix, int budget){
      |                                   ^
ricehub.cpp: In function 'int bsearch(int, int, int)':
ricehub.cpp:15:14: error: 'fred' was not declared in this scope
   15 |    int hub = fred[mid];
      |              ^~~~
ricehub.cpp:16:29: error: 'prefix' was not declared in this scope
   16 |    int one = ((m/2) * hub)-(prefix[mid-1]-prefix[i-m]);
      |                             ^~~~~~
ricehub.cpp:19:10: error: 'min' was not declared in this scope; did you mean 'mid'?
   19 |    ans = min(ans, one+two);
      |          ^~~
      |          mid
ricehub.cpp:21:13: error: 'budget' was not declared in this scope
   21 |   if(ans <= budget) l = m;
      |             ^~~~~~
ricehub.cpp: At global scope:
ricehub.cpp:29:29: error: 'vector' has not been declared
   29 | int besthub(int n, int len, vector<int>&x, int budget){
      |                             ^~~~~~
ricehub.cpp:29:35: error: expected ',' or '...' before '<' token
   29 | int besthub(int n, int len, vector<int>&x, int budget){
      |                                   ^
ricehub.cpp: In function 'int besthub(int, int, int)':
ricehub.cpp:30:2: error: 'vector' was not declared in this scope
   30 |  vector<int>prefix(n+1);
      |  ^~~~~~
ricehub.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include "ricehub.h"
  +++ |+#include <vector>
    3 | //#define int int64_t
ricehub.cpp:30:9: error: expected primary-expression before 'int'
   30 |  vector<int>prefix(n+1);
      |         ^~~
ricehub.cpp:32:3: error: 'prefix' was not declared in this scope
   32 |   prefix[i] = prefix[i-1] + x[i-1];
      |   ^~~~~~
ricehub.cpp:32:29: error: 'x' was not declared in this scope
   32 |   prefix[i] = prefix[i-1] + x[i-1];
      |                             ^
ricehub.cpp:35:9: error: expected primary-expression before 'int'
   35 |  vector<int>fred;
      |         ^~~
ricehub.cpp:36:2: error: 'fred' was not declared in this scope
   36 |  fred.push_back(0);
      |  ^~~~
ricehub.cpp:37:14: error: 'x' was not declared in this scope
   37 |  for(auto u: x) fred.push_back(u);
      |              ^
ricehub.cpp:39:31: error: 'prefix' was not declared in this scope
   39 |  return bsearch(n, len, fred, prefix, budget);
      |                               ^~~~~~
ricehub.cpp:39:39: error: 'budget' was not declared in this scope
   39 |  return bsearch(n, len, fred, prefix, budget);
      |                                       ^~~~~~