# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290906 | arayi | Boxes with souvenirs (IOI15_boxes) | C++17 | 2093 ms | 27768 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;
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--)
{
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]);
}
for (int l = 0; l < n; l++)
{
for (int r = l; r < n; r++)
{
lli sm = ((r - l) / k + 1) * 1LL * L;
if(l) sm += dp[l - 1];
if(r < n - 1) sm += dp1[r + 1];
pat = min(pat, sm);
}
}
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... |