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>
long long cost[10000007];
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
if(N == 1) return min(p[0], L - p[0]);
long long cur = 0;
for(int i = 0, j = 0; i < N; i++) {
if((j+=1) == K) j = 0;
cost[i] = cur + p[i];
if(j == 0) cur += p[i];
}
long long ans = cost[N - 1];
for(int i = N - 1, j = 0; i >= 0; i--) {
if((j+=1) == K) j = 0;
cost[i] = cur + L - p[i];
if(j == 0) cur += L - p[i];
if(i!=0) ans = min(ans, cost[i] + cost[i - 1]);
}
ans = min(ans, cost[0]);
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... |