# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624893 | brucecccccc | Boxes with souvenirs (IOI15_boxes) | C++14 | 2069 ms | 29508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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[j] + min(p[j], L - p[j]);
// cout << forward[j-K] + p[i] << endl;
}
i++;
}
i = N-1;
while (i >= 0 && backward[i] == 0) {
backward[i] = L - p[i] + min(p[i], L - p[i]);
for (int j = i - K; j >= 0; j -= K) {
backward[j] = backward[j+K] + L - p[j] + min(p[j], 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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |