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;
#define ll long long
ll dp[10000005];
ll dp1[10000005];
long long delivery(int n, int k, int l, int p[])
{
for (int i = 1; i <= n; i++)
{
if (i >= k) dp[i] = dp[i-k]+2ll*(p[i-1]);
else dp[i] = 2ll*(p[i-1]);
}
for (int i = 1; i <= n; i++)
{
if (i >= k) dp1[i] = dp1[i-k]+2ll*(l-p[n-i]);
else dp1[i] = 2ll*(l-p[n-i]);
}
ll rez = dp[n];
for (int i = 0; i <= n; i++)
{
rez = min(rez, dp[i]+dp1[n-i]);
if (n-i-k >= 0)
rez = min(rez, dp[i]+dp1[n-i-k]+l);
}
return rez;
}
# | 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... |