제출 #419152

#제출 시각아이디문제언어결과실행 시간메모리
419152LouayFarah선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "boxes.h" using namespace std; int delivery(int n, int k, int l, int positions[]) { if(k==1) { int res = 0; for(int i = 0; i<n; i++) { if(positions[i]>l/2) { res+=2*(l-positions[i]); } else { res+=2*(positions[i]); } } return res; } else if(k==n) { ll a = 0, b = 0, c = 0, d = 1e18; a = l; b = 2*positions[n-1]; c = 2*(l - positions[0]); ll left = -1, right = 0; for(int i = 0; i<n; i++) { if(positions[i]>=l/2) { if(i>0) { left = positions[i]; right = positions[i-1]; break; } else break; } } if(left!=-1) d = 2*(l - left) + 2*right; return min(min(a,b), min(c, d)); } else { } }

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

boxes.cpp:5:5: error: ambiguating new declaration of 'int delivery(int, int, int, int*)'
    5 | int delivery(int n, int k, int l, int positions[])
      |     ^~~~~~~~
In file included from boxes.cpp:2:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
    4 | long long delivery(int N, int K, int L, int p[]);
      |           ^~~~~~~~
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:25:9: error: 'll' was not declared in this scope; did you mean 'l'?
   25 |         ll a = 0, b = 0, c = 0, d = 1e18;
      |         ^~
      |         l
boxes.cpp:26:9: error: 'a' was not declared in this scope
   26 |         a = l;
      |         ^
boxes.cpp:27:9: error: 'b' was not declared in this scope
   27 |         b = 2*positions[n-1];
      |         ^
boxes.cpp:28:9: error: 'c' was not declared in this scope
   28 |         c = 2*(l - positions[0]);
      |         ^
boxes.cpp:29:11: error: expected ';' before 'left'
   29 |         ll left = -1, right = 0;
      |           ^~~~~
      |           ;
boxes.cpp:36:26: error: assignment of function 'std::ios_base& std::left(std::ios_base&)'
   36 |                     left = positions[i];
      |                     ~~~~~^~~~~~~~~~~~~~
boxes.cpp:37:27: error: assignment of function 'std::ios_base& std::right(std::ios_base&)'
   37 |                     right = positions[i-1];
      |                     ~~~~~~^~~~~~~~~~~~~~~~
boxes.cpp:45:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   45 |         if(left!=-1)
      |            ~~~~^~~~
boxes.cpp:46:13: error: 'd' was not declared in this scope
   46 |             d = 2*(l - left) + 2*right;
      |             ^
boxes.cpp:46:22: error: invalid operands of types 'int' and 'std::ios_base&(std::ios_base&)' to binary 'operator-'
   46 |             d = 2*(l - left) + 2*right;
      |                    ~ ^ ~~~~
      |                    |   |
      |                    int std::ios_base&(std::ios_base&)
boxes.cpp:46:33: error: invalid operands of types 'int' and 'std::ios_base&(std::ios_base&)' to binary 'operator*'
   46 |             d = 2*(l - left) + 2*right;
      |                                ~^~~~~~
      |                                | |
      |                                | std::ios_base&(std::ios_base&)
      |                                int
boxes.cpp:48:37: error: 'd' was not declared in this scope
   48 |         return min(min(a,b), min(c, d));
      |                                     ^