Submission #134532

#TimeUsernameProblemLanguageResultExecution timeMemory
13453220160161simoneBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define M 10000010 #define inf 0x3f3f3f int mi[M]; long long delivery(int N, int K, int L, int p[]) { for(int i=1;i<=N;i++){ mi[i]=min(abs(L-p[i]),abs(p[i]))*2; } sort(mi+1,mi+1+N); int ans=0,val=0,k=0; for(int i=1;i<=N;i++) { k++; val=max(mi[i],val); if(k==K) { ans+=val; val=0; k=0; } } ans+=val; return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:8:12: error: 'min' was not declared in this scope
      mi[i]=min(abs(L-p[i]),abs(p[i]))*2;  
            ^~~
boxes.cpp:8:12: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
boxes.cpp:10:2: error: 'sort' was not declared in this scope
  sort(mi+1,mi+1+N);
  ^~~~
boxes.cpp:10:2: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4856:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^~~~
boxes.cpp:15:7: error: 'max' was not declared in this scope
   val=max(mi[i],val);
       ^~~
boxes.cpp:15:7: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~