Submission #1073702

#TimeUsernameProblemLanguageResultExecution timeMemory
1073702Dan4LifeFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h" #include <algorithm> int findSample(int n, int c[], int h[], int p[]){ int ans = 0, i; // Mind-blown! for(int i = n; i>0; i--){ if(p[i]==2) c[h[i]]=max(c[h[i]],c[i]); else if(p[i]==1) c[h[i]]+=c[i]; else ans+=c[i], c[h[i]]=max(0, c[h[i]]-c[i]); } return c[0]+ans; }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:6:29: error: 'max' was not declared in this scope; did you mean 'std::max'?
    6 |         if(p[i]==2) c[h[i]]=max(c[h[i]],c[i]);
      |                             ^~~
      |                             std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from friend.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)
      |     ^~~
friend.cpp:8:33: error: 'max' was not declared in this scope; did you mean 'std::max'?
    8 |         else ans+=c[i], c[h[i]]=max(0, c[h[i]]-c[i]);
      |                                 ^~~
      |                                 std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from friend.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)
      |     ^~~
friend.cpp:4:18: warning: unused variable 'i' [-Wunused-variable]
    4 |     int ans = 0, i; // Mind-blown!
      |                  ^