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 maxn = 1e7+5;
const long long INF = 1e18;
long long cnt[maxn], ans[maxn], dp[maxn];
long long delivery(int N, int K, int L, int p[]) {
sort(p, p+N);
long long re = 0;
for(int i = 0; i < N; i++){
N -= (p[i] == 0);
re += 2*min(p[i], L - p[i]);
}
if(N == 0)return 0;
int crr = 0;
for(int i = 0; i < N; i++){
if(p[i]==0)continue;
dp[crr++%K] += p[i] + min(p[i], L - p[i]);
ans[crr] = dp[(crr-1)%K];
}
memset(dp, 0, sizeof(dp));
crr = 0;
for(int i = N-1; i >= 0; i--){
if(p[i]==0)continue;
dp[crr++%K] += L - p[i] + min(p[i], L - p[i]);
re = min(re, dp[(crr-1)%K] + ans[N - crr]);
}
return re;
}
# | 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... |