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 F first
#define S second
#define pii pair<int, int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = 1e7 + 10;
ll dp[maxN], pd[maxN];
long long delivery(int n, int k, int L, int p[]) {
for (int i=1; i<=n; i++)
{
int j = max(0, i - k);
dp[i] = dp[j] + min((ll)L, 2LL * p[i - 1]);
}
for (int i=n-1; i>=0; i--)
{
int j = min(n, i + k);
pd[i] = pd[j] + min((ll)L, 2LL*(L - p[i]));
}
ll ans = (ll)n * L;
for (int i=0; i<=n; i++)
ans = min(ans, dp[i] + pd[i]);
return ans;
}
# | 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... |