제출 #319530

#제출 시각아이디문제언어결과실행 시간메모리
319530tjdgus4384선물상자 (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){ int i, ans = 0; for(i = 0;i + K - 1 < N;i += K){ if(positions[i] > L/2) ans += (L-positions[i])*2; else if(positions[i + K - 1] < L/2) ans += (positions[i + K - 1])*2; else{ for(int j = i+1;j <= i + K - 1;j++){ if(positions[j+1]-positions[j] > L/2){ ans += (L-positions[j+1]+positions[j])*2; goto next; } } ans += L; } next:; } return ans; }

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

boxes.cpp:5:41: error: expected ',' or '...' before 'positions'
    5 | int delivery(int N, int K, int L, int[] positions){
      |                                         ^~~~~~~~~
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:8:12: error: 'positions' was not declared in this scope
    8 |         if(positions[i] > L/2) ans += (L-positions[i])*2;
      |            ^~~~~~~~~