Submission #600228

#TimeUsernameProblemLanguageResultExecution timeMemory
600228_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 R, int L, int X[], long long B){ int n = R; int len = L; int budget = B; 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: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:40:14: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   40 |  for(auto u: X) fred.push_back(u);
      |              ^
      |              std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from ricehub.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
ricehub.cpp:40:14: error: 'end' was not declared in this scope; did you mean 'std::end'?
   40 |  for(auto u: X) fred.push_back(u);
      |              ^
      |              std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from ricehub.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~