# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424387 | SuhaibSawalha1 | Boxes with souvenirs (IOI15_boxes) | C++17 | 50 ms | 21676 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;
const int N = 1000;
long long dp[N][N];
int a[N], n, l, k;
int f (int i, int j) {
return min({l, 2 * a[j], 2 * (l - a[i])});
}
long long calc (int i = 0, int s = 0) {
if (i == n) {
return s ? f(i - s, i - 1) : 0;
}
long long &ret = dp[i][s];
if (~ret) {
return ret;
}
ret = calc(i + 1, 0) + f(i - s, i);
if (s + 1 != k) {
ret = min(ret, calc(i + 1, s + 1));
}
return ret;
}
long long delivery(int N, int K, int L, int p[]) {
n = N;
l = L;
k = K;
memset(dp, -1, sizeof dp);
for (int i = 0; i < N; ++i) {
a[i] = p[i];
}
return calc();
}
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... |