This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("Ofast")
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 10000000;
int n, k, l, p[N];
ll dp[2][N];
ll delivery(int NN, int K, int L, int P[]) {
n = NN;
k = K;
l = L;
for (int i = 0; i < n; i++) {
p[i] = P[i];
}
for (int i = 0; i < n; i++) {
dp[0][i] = p[i] + min(p[i], l-p[i]) + (i-k >= 0 ? dp[0][i-k] : 0);
}
ll ans = dp[0][n-1];
for (int i = n-1; i >= 0; i--) {
dp[1][i] = l-p[i] + min(l-p[i], p[i]) + (i+k < n ? dp[1][i+k] : 0);
ans = min(ans, (i ? dp[0][i-1] : 0) + dp[1][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... |