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 delivery(int n, int k, int l, int p11[]) {
vector<ll> p(n);
for (int i = 0; i < n; i++) p[i] = p11[i];
if (k == 1) {
ll sum = 0;
for (auto &e : p) sum += 2*min(e, l-e);
return sum;
}
ll fR = lower_bound(p.begin(), p.end(), l/2) - p.begin();
if (fR == 0) return 2*(l-p[fR]);
ll fL = fR-1;
if (fL == n-1) return 2*p[fL];
return p[fL] + l-p[fR] + min(p[fR]-p[fL], l-(p[fR]-p[fL]));
}
# | 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... |