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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e7+5;
ll pref[N],suf[N];
long long delivery(int n, int k, int L, int p[]) {
ll ans=1e18;
for(int i=0;i<n;i++){
if(i<k) pref[i+1]=p[i]*2;
else pref[i+1]=pref[i+1-k]+p[i]*2;
}
for(int i=n-1;i>=0;i--){
if(i+k+1>n) suf[i+1]=2*(L-p[i]);
else suf[i+1]=suf[i+k+1]+2*(L-p[i]);
}
for(int i=0;i<=n;i++){
ans=min(ans,pref[i]+suf[i+1]);
ans=min(ans,pref[i]+L+suf[min(n+1,i+k+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... |