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"
using namespace std;
long long a[10000005], dp[10000005], dp1[10000005], ans = 1e18;
long long delivery(int N, int K, int L, int p[]) {
for (int i = 0;i < N;i++){
a[i] = L - p[N - 1 - i] + 1;
if (i < K) {
dp[i + 1] = p[i] * 2;
dp1[i + 1] = a[i] * 2;
}
else {
dp[i + 1] = dp[i - K + 1] + p[i] * 2;
dp1[i + 1] = dp1[i - K + 1] + a[i] * 2;
}
}
for (int i = 0;i <= N;i++){
ans = min(ans, dp[i] + dp[N - i]);
if (i + K <= N) ans = min(ans, dp[i] + L + dp1[N - i - K]);
}
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... |