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;
typedef long long LL;
LL delivery(int N, int K, int L, int p[])
{
sort(p, p + N);
int cnt0 = 0;
for(int i = 0; i < N; i++)
if(p[i] == 0)
cnt0++;
if(cnt0)
{
for(int i = cnt0; i < N; i++)
p[i - cnt0] = p[i];
N -= cnt0;
}
vector<LL> pfx(N + 5), sfx(N + 5);
for(int i = 0; i < N; i++)
{
pfx[i] = p[i];
if(i >= K) pfx[i] += pfx[i - K];
}
for(int i = N - 1; i >= 0; i--)
{
sfx[i] = (L - p[i]);
if(i + K < N) sfx[i] += sfx[i + K];
}
LL ans = 1LL << 60;
for(int i = 0; i < N; i++)
ans = min(ans, pfx[i] + sfx[i + 1]);
ans *= 2LL;
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... |