# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290923 | arayi | Boxes with souvenirs (IOI15_boxes) | C++17 | 646 ms | 391808 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 <bits/stdc++.h>
#include "boxes.h"
#define lli long long int
using namespace std;
const int N = 1e7 + 20;
lli a[N], l;
int n, k;
lli dp[N], dp1[N], pat = LLONG_MAX, mn[N];
long long delivery(int N, int K, int L, int p[])
{
n = N, k = K, l = L;
for (int i = 0; i < n; i++) a[i] = p[i];
for (int i = 0; i < n; i++)
{
dp[i] = a[i] + a[i];
if(i >= k) dp[i] += dp[i - k];
}
pat = dp[n - 1];
for(int i = n - 1; i >= 0; i--)
{
mn[i] = l * 2LL * n;
dp1[i] = l - a[i] + l - a[i];
if(n - i > k) dp1[i] += dp1[i + k];
if(i) pat = min(pat, dp1[i] + dp[i - 1]);
else pat = min(pat, dp1[0]);
}
pat = min(dp[n - 1], dp1[0]);
mn[n % k] = (n / k) * l;
for(int i = n - 1; i >= 0; i--)
{
mn[i % k] = min(mn[i % k], (i / k) * l + dp1[i]);
if(i)
{
lli sm = dp[i - 1] + mn[i % k] - (i / k) * l;
pat = min(pat, sm);
}
else pat = min(pat, mn[0]);
}
return pat;
}
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... |