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>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
sort(p, p + N);
vector<long long> l(K), r(K);
for(int i = 0; i < N; i++)
l[(i + 1) % K] += min(2 * p[i], L);
long long ans = l[N % K];
for(int i = N - 1; i >= 0; i--) {
l[(i + 1) % K] -= min(2 * p[i], L);
r[i % K] += min(2 * (L - p[i]), L);
ans = min(ans, l[i % K] + r[i % 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... |