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
long long delivery(int n, int k, int L, int p[]) {
ll ans=1e18;
vector<ll> pref(n+1),suf(n+1);
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;
if(i<k) suf[i+1]=(L-p[n-i-1])*2;
else suf[i+1]=suf[i+1-k]+(L-p[n-i-1]*2);
}
for(int i=0;i<=n;i++){
for(int j=i;j<=n;j+=k){
ll x=(ll)(j-i)/k*L;
x+=pref[i];
x+=suf[n-j];
ans=min(ans,x);
}
}
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... |