# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624894 | brucecccccc | Boxes with souvenirs (IOI15_boxes) | C++14 | 2074 ms | 19948 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;
const int MAXN = 1e7+5;
ll f[MAXN], b[MAXN];
ll delivery(int N, int K, int L, int p[]) {
int i = 0;
while (i < N && f[i] == 0) {
f[i] = p[i] + min(p[i], L - p[i]);
for (int j = i + K; j < N; j += K) {
f[j] = f[j-K] + p[j] + min(p[j], L - p[j]);
}
i++;
}
i = N-1;
while (i >= 0 && b[i] == 0) {
b[i] = L - p[i] + min(p[i], L - p[i]);
for (int j = i - K; j >= 0; j -= K) {
b[j] = b[j+K] + L - p[j] + min(p[j], L - p[j]);
}
i--;
}
ll ans = min(f[N-1], b[0]);
for (int i = 0; i < N - 1; i++) {
ans = min(ans, f[i] + b[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... |