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 pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 1e7 + 5;
ll l[maxn], r[maxn];
ll delivery(int N, int K, int L, int p[]) {
for(int i = 0;i < N;i++) {
l[i] = 2 * p[i];
if(i >= K) l[i] += l[i - K];
}
for(int i = N - 1;i >= 0;i--) {
r[i] = 2 * (L - p[i]);
if(i + K < N)
r[i] += r[i - K];
}
ll ans = r[0];
for(int i = 0;i < N;i++)
ans = min(ans, l[i] + r[i + 1]);
for(int i = 0;i + K < N;i++)
ans = min(ans, l[i] + r[i + K + 1] + (ll)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... |