Submission #530214

#TimeUsernameProblemLanguageResultExecution timeMemory
530214Icebear16Distributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include "candies.h" #include <bits/stdc++.h> 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=l.size(); std::vector<int> s(n,0); bool flag=true; for(int i=0;i<q;i++){ if(v[i]<0){ flag=false; break; } } if(flag==false){ for(int j=0;j<q;j++){ for(int i=l[j];i<=r[j];i++){ if(v[j]>=0){ s[i]=max(c[i],s[i]+v[j]); }else{ s[i]=max(c[i],s[i]+v[j]); } } } }else{ s.push_back(0); for(int j=0;j<q;j++){ s[l[j]]+=v[j]; s[r[j+1]]-=v[j]; } for(int i=1;i<=n;i++){ s[i]+=s[i-1]; } reverse(s.begin(),s.end()); s.pop_back(); reverse(s.begin(),s.end()); } 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:19:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   19 |      s[i]=max(c[i],s[i]+v[j]);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:21:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   21 |      s[i]=max(c[i],s[i]+v[j]);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~