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;
#define ll long long
ll delivery(int n, int k, int l, int p[]) {
sort(p, p + n);
vector<int> q;
for(int i = 0; i < n; i ++)
if(p[i] != 0)
q.push_back(p[i]);
n = (int)q.size();
auto get = [&](ll x) {return min(x, l - x);};
vector<ll> pref(n + 1), suff(n + 1);
for(int i = 0; i < n; i ++)
pref[i + 1] = (i + 1 < k ? 0 : pref[i + 1 - k]) + q[i] + get(q[i]);
for(int i = n - 1; i >= 0; i --)
suff[i] = (i + k > n ? 0 : suff[i + k]) + l - q[i] + get(q[i]);
ll ans = 1e18;
for(int i = 0; i <= n; i ++)
ans = min(ans, pref[i] + suff[i]);
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... |