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>
using namespace std;
#define LINF 1023456789123456789
typedef long long ll;
#define maxn 10000005
ll pfx[maxn], sfx[maxn];
ll delivery(int N, int K, int L, int p[]){
sort(p, p + N);
for (int i = 0; i < N; ++i) {
if (2 * p[i] > L) {
sfx[i % K] += (L - p[i]) * 2;
}
else {
sfx[i % K] += L;
}
}
ll ans = LINF;
for (int i = 0; i < N; ++i) {
if (2 * p[i] < L) {
pfx[i % K] += p[i] * 2;
sfx[i % K] -= L;
}
else {
pfx[i % K] += L;
sfx[i % K] -= (L - p[i]) * 2;
}
ans = min(ans, pfx[i % K] + sfx[(i + 1) % K]);
}
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... |