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>
#include "boxes.h"
using namespace std;
typedef long long ll;
const int MAXN = 1e7 + 10;
const ll INF = 1e18;
ll l[MAXN] , r[MAXN];
long long delivery(int N, int K, int L, int p[]) {
for(int i = 0 ; i < N ; i++){
l[i] = p[i] * 2;
r[i] = (L - p[i]) * 2;
}
for(int i = K ; i < N ; i++) l[i] += l[i - K];
for(int i = N - K ; i >= 0 ; i--) r[i] += r[i + K];
ll ans = min(l[N - 1] , r[0]);
for(int i = 1 ; i < N ; i++) ans = min(ans , l[i - 1] + r[i]);
for(int i = 0 ; i + K <= N ; i++){
ans = min(ans , (i == 0 ? 0 : l[i - 1]) + r[i + K] + L);
}
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... |