제출 #618862

#제출 시각아이디문제언어결과실행 시간메모리
618862A_D선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> const int N=1e7+10; long long pre[N]; long long suf[N]; long long delivery(int N, int K, int L, int p[]) { sort(p,p+N); long long ans=1e18; long long me=0,cur=0,lst=0; for(int i=0;i<N;i++){ long long h=p[i]; me+=h-lst; cur++; pre[i]=me+min(h,N-h); if(cur==k){ me+=min(h,N-h); cur=0; me+=h; } lst=p[i]; } ans=pre[N-1]; me=0,cur=0,lst=0; for(int i=N-1;i>=0;i--){ long long h=p[i]; me+=abs(h-lst); cur++; suf[i]=me+min(h,N-h); if(cur==k){ me+=min(h,N-h); cur=0; me+=N-h; } lst=p[i]; } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:24: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   11 | long long delivery(int N, int K, int L, int p[]) {
      |                    ~~~~^
boxes.cpp:5:11: note: shadowed declaration is here
    5 | const int N=1e7+10;
      |           ^
boxes.cpp:13:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |     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:3:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: 'std::sort' declared here
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
boxes.cpp:23:19: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |         pre[i]=me+min(h,N-h);
      |                   ^~~
      |                   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:3:
/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:24:17: error: 'k' was not declared in this scope
   24 |         if(cur==k){
      |                 ^
boxes.cpp:37:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |         me+=abs(h-lst);
      |                 ~^~~~
boxes.cpp:39:19: error: 'min' was not declared in this scope; did you mean 'std::min'?
   39 |         suf[i]=me+min(h,N-h);
      |                   ^~~
      |                   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:3:
/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:40:17: error: 'k' was not declared in this scope
   40 |         if(cur==k){
      |                 ^
boxes.cpp:11:31: warning: unused parameter 'K' [-Wunused-parameter]
   11 | long long delivery(int N, int K, int L, int p[]) {
      |                           ~~~~^
boxes.cpp:11:38: warning: unused parameter 'L' [-Wunused-parameter]
   11 | long long delivery(int N, int K, int L, int p[]) {
      |                                  ~~~~^