제출 #624883

#제출 시각아이디문제언어결과실행 시간메모리
624883brucecccccc선물상자 (IOI15_boxes)C++14
10 / 100
1 ms308 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll delivery(int N, int K, int L, int p[]) { vector<ll> forward(N), backward(N); int i = 0; while (i < N && forward[i] == 0) { forward[i] = p[i] * 2; for (int j = i + K; j < N; j += K) { forward[j] = forward[j-K] + 2 * p[j]; } i++; } i = N-1; while (i >= 0 && backward[i] == 0) { backward[i] = (L - p[i]) * 2; for (int j = i - K; j >= 0; j -= K) { backward[j] = backward[j+K] + 2 * (L - p[j]); } i--; } ll ans = min(forward[N-1], backward[0]); for (int i = 0; i < N - 1; i++) { ans = min(ans, forward[i] + backward[i+1]); } return ans; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:29:12: warning: declaration of 'i' shadows a previous local [-Wshadow]
   29 |   for (int i = 0; i < N - 1; i++) {
      |            ^
boxes.cpp:10:7: note: shadowed declaration is here
   10 |   int i = 0;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...