제출 #282745

#제출 시각아이디문제언어결과실행 시간메모리
282745JoseCopas선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include "bits/stdc++.h" /* using namespace std; */ long long delivery(int N, int K, int L, int p[]) { int c=0; if(K==1) { sort(p, p+N); for(int i=0;i<N;i++) { //cout<<p[i]<<" "; c+=min(L-p[i], p[i]); } } cout<<c<<"\n"; return 0; } /* int main() { int n,k,l; cin>>n>>k>>l; int v[n]; for(int i=0;i<n;i++)cin>>v[i]; delivery(n,k,l,v); } */

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |         sort(p, p+N);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:3:
/usr/include/c++/9/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
boxes.cpp:16:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   16 |             c+=min(L-p[i], p[i]);
      |                ^~~
      |                std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:19:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |     cout<<c<<"\n";
      |     ^~~~
      |     std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:75,
                 from boxes.cpp:3:
/usr/include/c++/9/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~