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>
#define fi first
#define se second
#define ll long long
#define dl double
using namespace std;
ll delivery(int N, int K, int LE, int P[])
{
vector<ll> d(N + 1, 1e18);
d[0] = 0;
vector<ll> p(N + 1, 0);
for(int i = 1; i <= N; i++)p[i] = P[i - 1];
sort(p.begin(), p.end());
vector<ll> L(N + 1, 0ll), R(N + 2, 0ll);
for(int i = 1; i <= N; i++){
L[i] = L[max(0, i - K)] + p[i] + p[i];
}
for(int i = N; i >= 1; i--){
R[i] = R[min(N + 1, i + K)] + (LE - p[i]) * 2ll;
}
ll ans = 1e18;
for(int i = 0; i <= N; i++){
ans = min(ans, L[i] + R[i + 1]);
}
for(int i = 1; i <= N; i++){
if(i + K - 1 > N)break;
ans = min(ans, L[i - 1] + R[i + K] + LE);
}
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... |