제출 #206935

#제출 시각아이디문제언어결과실행 시간메모리
206935Kenzo_1114선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; const int MAXN = 10000010; int N, K, L, POSITIONS[MAXN]; long long int ans[MAXN], po[MAXN]; long long int delivery(int n, int k, int l, int positions[]) { int id1 = 0, id2 = 0; for(int i = 0; i < n; i++) pos[i + 1] = positions[i]; for(int i = 1; i <= n; i++) if(pos[i] > l / 2) { id1 = i - 1; id2 = i; break; } for(int i = 1; i <= id1; i++) ans[i] = 2 * pos[i] + ans[(i / k) * k]; for(int i = n; i > id1; i--) ans[i] = 2 * (l - pos[i]) + ans[n + 1 - ((n - i + 1) / k) * k]; long long int ANS = ans[id1] + ans[id2]; id1 = (id1 / k) * k; id2 = n + 1 - ((n - id2) / k) * k; long long int ANS2 = ans[id1] + l + ans[id1 + k + 1]; long long int ANS3 = ans[id2] + l + ans[id2 - k - 1]; // printf("ans[%d](%lld) + %d + ans[%d](%lld)\n", id2, ans[id2], l, id2 - k - 1, ans[id2 - k - 1]); // printf("ans = %lld ans2 = %lld ans3 = %lld\n", ANS, ANS2, ANS3); return min(ANS, min(ANS2, ANS3)); } /* int main () { scanf("%d %d %d", &N ,&K, &L); for(int i = 0; i < N; i++) scanf("%d", &POSITIONS[i]); printf("%lld\n",delivery(N, K, L, POSITIONS)); } */ /* 4 2 8 1 2 3 5 */

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:29: error: 'pos' was not declared in this scope
  for(int i = 0; i < n; i++) pos[i + 1] = positions[i];
                             ^~~
boxes.cpp:13:29: note: suggested alternative: 'po'
  for(int i = 0; i < n; i++) pos[i + 1] = positions[i];
                             ^~~
                             po
boxes.cpp:16:6: error: 'pos' was not declared in this scope
   if(pos[i] > l / 2)
      ^~~
boxes.cpp:16:6: note: suggested alternative: 'po'
   if(pos[i] > l / 2)
      ^~~
      po
boxes.cpp:20:16: error: 'pos' was not declared in this scope
   ans[i] = 2 * pos[i] + ans[(i / k) * k];
                ^~~
boxes.cpp:20:16: note: suggested alternative: 'po'
   ans[i] = 2 * pos[i] + ans[(i / k) * k];
                ^~~
                po
boxes.cpp:23:21: error: 'pos' was not declared in this scope
   ans[i] = 2 * (l - pos[i]) + ans[n + 1 - ((n - i + 1) / k) * k];
                     ^~~
boxes.cpp:23:21: note: suggested alternative: 'po'
   ans[i] = 2 * (l - pos[i]) + ans[n + 1 - ((n - i + 1) / k) * k];
                     ^~~
                     po