# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65560 | daniel_02 | Boxes with souvenirs (IOI15_boxes) | C++17 | 518 ms | 196072 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>
#define ll long long
using namespace std;
const int N = 1e7 + 3;
ll dp[N], dp_suf[N];
long long delivery(int N, int K, int L, int p[]) {
long long ans, res = 0;
ans = 1LL * 1e18 + 7;
for (int i = 0; i < N; i++)
{
if (i < K)
{
dp[i] = p[i] + min(L - p[i], p[i]);
}
else
{
dp[i] = (p[i] + min(L - p[i], p[i])) + dp[i - K];
}
}
for (int i = N - 1; i >= 0; i--)
{
if (N - i - 1 < K)
{
dp_suf[i] = (L - p[i]) + min(L - p[i], p[i]);
}
else
{
dp_suf[i] = ((L - p[i]) + min(L - p[i], p[i])) + dp_suf[i + K];
}
}
for (int i = 0; i < N; i++){
ans = min(ans, dp[i] + dp_suf[i + 1]);
}
for (int i = 0; i < N; i += K)
{
res += (L - p[i]) + min(p[i], L - p[i]);
}
ans = min(ans, res);
return ans;
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... |