제출 #421362

#제출 시각아이디문제언어결과실행 시간메모리
421362jlallas384선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; ll delivery(int n, int k, int l, int pi[]) { ll ans = 0; vector<int> p(n+2); for(int i = 1; i <= n; i++){ p[i] = pi[i-1]; } for(int i = 0; i < n; i++){ ans += min(p[i+1] - p[i],p[i] + l - p[i+1]); } return ans + min(p[i],l - p[i]); }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:14:24: error: 'i' was not declared in this scope
   14 |     return ans + min(p[i],l - p[i]);
      |                        ^
boxes.cpp:5:24: warning: unused parameter 'k' [-Wunused-parameter]
    5 | ll delivery(int n, int k, int l, int pi[]) {
      |                    ~~~~^