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 cw[10000001], ccw[10000001];
long long delivery(int N, int K, int L, int p[]) {
for(int i = 0; i < N; i++){
if(i - K < 0) cw[i] = (p[i] * 1ll) << 1;
else cw[i] = cw[i - K] + ((p[i] * 1ll) << 1);
}
for(int i = N - 1; i >= 0; i--){
if(i + K > N - 1) ccw[i] = ((L - p[i]) * 1ll) << 1;
else ccw[i] = ccw[i + K] + (((L - p[i]) * 1ll) << 1);
}
long long ans = min(cw[N - 1], ccw[0]);
for(int i = 0; i < N - 1; i++) ans = min(ans, cw[i] + ccw[i + 1]);
for(int i = 0; i + K + 1 < N; i++) ans = min(ans, cw[i] + ccw[i + K + 1] + (L * 1ll));
if(K >= N) ans = min(ans, L * 1ll);
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... |