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;
typedef long long ll;
ll left(int n, int k, int l, vector<ll> p, int first) {
ll sum = 0;
ll pos = 0;
for (int i = 0; i < n; i++) {
sum += min(abs(p[i]-pos), l-abs(p[i]-pos));
pos = p[i];
if ((i+1+first) % k == 0) {
sum += min(pos, l-pos);
pos = 0;
}
}
return sum + min(pos, l-pos);
}
ll delivery(int n, int k, int l, int p11[]) {
vector<ll> p(n);
for (int i = 0; i < n; i++) p[i] = p11[i];
ll res = 1ll << 62ll;
for (int i = 0; i < k; i++) {
res = min(res, left(n, k, l, p, i));
}
return res;
}
# | 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... |