#include "boxes.h"
#include <algorithm>
long long delivery(int N, int K, int L, int p[]) {
int maxUnder = 0, minOver = 2000000000;
for (int i = 0; i < N; i++) {
if (p[i] > L/2) {
minOver = std::min(minOver, p[i]);
} else {
maxUnder = std::max(maxUnder, p[i]);
}
}
long long total = 0;
if (p[N-1] <= L/2) {
total = p[N-1] * 2;
} else if (p[0] > L/2) {
total = (L - p[0]) * 2;
} else {
total = L;
}
return std::min(total, static_cast<long long>(2*maxUnder + 2*(L-minOver)));
}
# | 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... |