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;
const int N = 10 * 1000 * 1000 + 5;
long long sl[N], sr[N];
long long delivery(int n, int k, int l, int a[]) {
sort(a, a + n);
// long long s = 0;
for (int i = 1; i <= n; i++) {
sl[i] = a[i - 1];
if (i - k > 0) {
sl[i] += sl[i - k];
}
}
for (int i = n; i; i--) {
sr[i] = l - a[i - 1];
if (i + k <= n) {
sr[i] += sr[i + k];
}
}
// for (int i = 0; i <= n; i++) {
// cout << "72 " << i << " " << sl[i] << " " << sr[i] << endl;
// }
long long ans = sl[n] * 2;
for (int i = 0; i <= n; i++) {
ans = min(ans, (sl[i] + sr[i + 1]) * 2);
if (i + k <= n) {
ans = min(ans, (sl[i] + sr[i + k + 1]) * 2 + l);
}
}
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... |