Submission #485665

#TimeUsernameProblemLanguageResultExecution timeMemory
485665antontsiorvasDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include "candies.h" #include <vector> const int root = 450; int buck[500]; std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { int n = c.size(), q = l.size(); std::vector<int> s(n); for(int i=0; i<q; i++){ int sb = l[i]/root, lb = r[i]/root; int esb = (sb + 1)*root - 1, slb = lb*root; if(sb == lb){ for(int j=l[i]; j<=r[i]; j++){ if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]); else s[j] = max(0,s[j] + v[i]); } continue; } for(int j=l[i]; j<=esb; j++){ if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]); else s[j] = max(0,s[j] + v[i]); } for(int j=sb+1; j<=lb-1; j++){ if(v[i] > 0) buck[j] = min(c[j], buck[j] + v[i]); else buck[j] = max(0,buck[j] + v[i]); } for(int j=slb; j<=r[i]; j++){ if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]); else s[j] = max(0,s[j] + v[i]); } } for(int i=0; i<n; i++){ s[i] = min(c[i], s[i] + buck[i/root]); } return s; }

Compilation message (stderr)

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:18:28: error: 'min' was not declared in this scope; did you mean 'std::min'?
   18 |        if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                            ^~~
      |                            std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:19:20: error: 'max' was not declared in this scope; did you mean 'std::max'?
   19 |        else s[j] = max(0,s[j] + v[i]);
      |                    ^~~
      |                    std::max
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:24:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   24 |       if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:25:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   25 |       else s[j] = max(0,s[j] + v[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:28:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   28 |    if(v[i] > 0) buck[j] = min(c[j], buck[j] + v[i]);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:29:22: error: 'max' was not declared in this scope; did you mean 'std::max'?
   29 |       else buck[j] = max(0,buck[j] + v[i]);
      |                      ^~~
      |                      std::max
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:32:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   32 |    if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                        ^~~
      |                        std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:33:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   33 |       else s[j] = max(0,s[j] + v[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
candies.cpp:37:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   37 |   s[i] = min(c[i], s[i] + buck[i/root]);
      |          ^~~
      |          std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~