Submission #624886

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6248862022-08-09 00:44:49bruceccccccBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms312 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++;
}
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]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (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...