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] = min(2LL * p[i], 1LL * L);
if(i >= K) pfx[i] += pfx[i - K];
}
for(int i = N - 1; i >= 0; i--)
{
sfx[i] = min(2LL * (L - p[i]), 1LL * L);
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]);
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... |