# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127956 | SOIVIEONE | Boxes with souvenirs (IOI15_boxes) | C++14 | 588 ms | 215032 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;
long long delivery(int N, int K, int L, int p[])
{
long long dp[N+2], pd[N + 2];
long long n = N, k = K, l = L;
dp[0] = 0;
for(int i = 1; i <= n; i ++)
dp[i] = dp[max(0ll, i - k)] + p[i - 1] * 2ll;
pd[n + 1] = 0;
for(int i = n; i >= 1; i --)
pd[i] = pd[min(n + 1, i + k)] + (L-p[i - 1]) * 2ll;
long long ans = 1e18;
for(int i = 1; i <= n+1; i ++)
ans = min(ans, dp[i - 1] + pd[i]);
for(int i = 0; i < n; i ++)
{
if(i + k <= n)
ans = min(ans, l + dp[i] + pd[i + k + 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... |