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 ll long long
using namespace std;
const int MXN = 1e7;
ll sm[MXN];
ll delivery(int N, int K, int L, int p[]) {
vector<ll> pp;
pp.clear();
for(int i=0;i<N;i++) pp.push_back(p[i]);
sort(pp.begin(), pp.end());
vector<ll> pref(N), suff(N + 1);
for(int i=0;i<K;i++) sm[i] = 0ll;
for(int i=0;i<N;i++) {
sm[i%K] += 2ll * pp[i];
pref[i] = sm[i%K];
}
for(int i=0;i<K;i++) sm[i] = 0ll;
for(int i=N-1;i>=0;i--) {
sm[i%K] += 2ll * L - 2ll * pp[i];
suff[i] = sm[i%K];
}
suff[N] = 0ll;
vector<ll> solve(N);
for(int i=0;i<N;i++) {
solve[i] = pref[i];
if(i >= K) solve[i] = min(solve[i], solve[i - K] + 1ll * L);
}
ll ans = suff[0];
for(int i=0;i<N;i++) {
ans = min(ans, solve[i] + suff[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... |