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 delivery(int n, int k, int l, int p[]) {
int ans = INT_MAX;
for(int i = 0; i < n; i++){
int cur = 0, items = k, cost = 0, dist = 0;
for(int j = 0; j <= i; j++){
if(items == 0){
items = k;
cost += dist;
cur = 0;
dist = 0;
}
cost += (p[j] - cur);
dist += (p[j] - cur);
cur = p[j];
items--;
}
cost += dist;
items = k;
cur = 0;
dist = 0;
for(int j = n - 1; j > i; j--){
int nw = (l - 1) - p[j] + 1;
if(items == 0){
items = k;
cost += dist;
cur = 0;
dist = 0;
}
cost += (nw - cur);
dist += (nw - cur);
cur = nw;
items--;
}
ans = min(ans, cost + dist);
}
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... |