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>
using namespace std;
typedef long long ll;
const int maxn = 1e7+50;
ll pre[maxn],suf[maxn];
long long delivery(int n, int k, int l, int p[]) {
for(int i=0;i<n;i++){
pre[i] = 2ll*p[i];
if(i >= k)pre[i] += pre[i-k];
}
for(int i=n-1;i>=0;i--){
suf[i] = 2ll*(l - p[i]);
if(i + k < n)suf[i] += suf[i+k];
}
ll ans = min(pre[n-1],suf[0]);
for(int i=0;i<n-1;i++){
if(i+k+1 < n)ans = min(ans,pre[i] + l + suf[i+k+1]);
ans = min(ans,pre[i] + suf[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... |