Submission #624885

#TimeUsernameProblemLanguageResultExecution timeMemory
624885bruceccccccBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms212 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] + min(p[i], L - p[i]); for (int j = i + K; j < N; j += K) { forward[j] = forward[j-K] + p[i] + min(p[i], L - p[i]); } i++; } cout << forward[N-1] << endl; 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] + L - p[i] + min(p[i], L - p[i]); } 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; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:30:12: warning: declaration of 'i' shadows a previous local [-Wshadow]
   30 |   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...