Submission #438755

# Submission time Handle Problem Language Result Execution time Memory
438755 2021-06-28T14:49:42 Z MohamedFaresNebili Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"
#include <vector>

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(); int q = v.size();
    std::vector<int> s(n);
    for(int i=0;i<n;i++) s[i]=0;
    for(int i=0;i<q;i++) {
        int lo=l[i], hi=r[i];
        for(int k=lo;k<=hi;k++) {
            if(v[i]>0) { s[k]=min(v[i]+s[k], c[k]); }
            else { s[k]=max(v[i]+s[k], 0); }
        }
    }
    return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:12:31: error: 'min' was not declared in this scope; did you mean 'std::min'?
   12 |             if(v[i]>0) { s[k]=min(v[i]+s[k], c[k]); }
      |                               ^~~
      |                               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:13:25: error: 'max' was not declared in this scope; did you mean 'std::max'?
   13 |             else { s[k]=max(v[i]+s[k], 0); }
      |                         ^~~
      |                         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)
      |     ^~~