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;
long long cwtour[1000100], cwwtour[1000100];
long long delivery(int N, int K, int L, int p[]) {
for (int i = 0; i < N; i++) cwtour[i] = p[i] + (i>K?cwtour[i-K]:0);
for (int i = N-1; i >= 0; i--) cwwtour[i] = L-p[i] + (i+K>=N?cwwtour[i+K]:0);
long long ans = 1e18;
for (int i = 0; i < N-1; i++) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+1]);
for (int i = 0; i < N-K-1; i++) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+K+1]+L);
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... |