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>
#define pb push_back
using namespace std;
#include "boxes.h"
const long long inf = 1e18;
long long delivery(int N, int K, int L, int p[]) {
vector<long long> pos(N);
for(int i = 0; i < N; i++){
pos[i] = p[i];
}
vector<long long> dpl(N+1), dpr(N+1);
for(int i = 1; i <= N; i++){
if(i < K) dpl[i] = pos[i-1] * 2;
else dpl[i] = dpl[i - K] + pos[i-1] * 2;
}
for(int i = 1; i <= N; i++){
if(i < K) dpr[i] = (L - pos[N-i]) * 2;
else dpr[i] = dpr[i - K] + (L - pos[N-i]) * 2;
}
long long ans = inf;
for(int l = 0; l <= N; l++){
for(int r = 0; r <= N; r++){
if(l + r > N) break;
long long rem = N - l - r;
long long calc = dpl[l] + dpr[r] + ((rem + K - 1)/K) * L;
ans = min(ans, calc);
}
}
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... |