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;
#define rep(i , j , k) for (int i = j; i < (int)k; i++)
typedef long long ll;
typedef vector<ll> vl;
ll delivery(int N, int K, int Ll, int p[]) {
sort(p , p + N);
vl L(N) , R(N);
rep(i , 0 , N) {
L[i] = p[i];
L[i] = min(1ll * Ll , 2 * L[i]);
if (i >= K)
L[i] += L[i - K];
}
for (int i = N - 1; ~i; i--) {
R[i] = Ll - p[i];
R[i] = min(1ll * Ll , 2 * R[i]);
if (i + K < N)
R[i] += R[i + K];
}
ll ans = min(L[N - 1] , R[0]);
rep(i , 1 , N)
ans = min(ans , L[i - 1] + R[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... |