제출 #197462

#제출 시각아이디문제언어결과실행 시간메모리
197462AaronNaidu선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int delivery(int n, int k, int l, int positions[n]) { int sum = 0; if(k == 1) { for(int i = 0; i < n; i++) { sum += min(positions[i], n - positions[i]); } return sum; } sort(positions, positions + n); if(k == n) { if(positions[0] > (double) n/2) { return 2 * (n - positions[0]); } if(positions[n-1] < (double) n/2) { return 2 * positions[n-1]; } return n; } int delivered = 0; int frontIndex = 0; while (delivered < n) { int carrying = k; int current = 0; while (carrying and current) { /* code */ } } return n; } int main() { return 0; }

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

boxes.cpp:4:50: error: use of parameter outside function body before ']' token
 int delivery(int n, int k, int l, int positions[n]) {
                                                  ^
boxes.cpp: In function 'int delivery(...)':
boxes.cpp:6:8: error: 'k' was not declared in this scope
     if(k == 1) {
        ^
boxes.cpp:7:28: error: 'n' was not declared in this scope
         for(int i = 0; i < n; i++) {
                            ^
boxes.cpp:8:24: error: 'positions' was not declared in this scope
             sum += min(positions[i], n - positions[i]);
                        ^~~~~~~~~
boxes.cpp:12:10: error: 'positions' was not declared in this scope
     sort(positions, positions + n);
          ^~~~~~~~~
boxes.cpp:12:33: error: 'n' was not declared in this scope
     sort(positions, positions + n);
                                 ^
boxes.cpp:12:33: note: suggested alternative: 'yn'
     sort(positions, positions + n);
                                 ^
                                 yn
boxes.cpp:13:8: error: 'k' was not declared in this scope
     if(k == n) {
        ^
boxes.cpp:28:24: error: 'k' was not declared in this scope
         int carrying = k;
                        ^
boxes.cpp:24:9: warning: unused variable 'frontIndex' [-Wunused-variable]
     int frontIndex = 0;
         ^~~~~~~~~~