Submission #444575

#TimeUsernameProblemLanguageResultExecution timeMemory
444575osmanallazovBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long long long delivery(int N, int K, int L, int p[]) { ll res=0; if(K==1){ for(int i=0;i<N;i++){ if(p[i]==0){ res+=0; } else if(p[i]<=L/2){ res+=(p[i]*2); } else{ res+=((L-p[i])*2); } } } else if(K==N){ res=L; sort(p,p+N); for(int i=0;i<N-1;i++){ res=min(res,(p[i]+L-p[i+1])*2); } res=min(res,L); } return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:21:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   21 |         sort(p,p+N);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: 'std::sort' declared here
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
boxes.cpp:23:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |             res=min(res,(p[i]+L-p[i+1])*2);
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:25:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   25 |         res=min(res,L);
      |             ^~~
      |             std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~