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;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(),x.end()
using ll = long long;
const ll inf = 1e18;
ll delivery(int n, int k, int l, int p[]) {
#define int ll
vector<int> a; forn(i,n) a.pb(p[i]);
vector<int> dp1,dp2;
dp1.pb(0);
forn(i,n) {
if (i<k) dp1.pb(min(2*a[i],1ll*l));
else dp1.pb(min(2*a[i],1ll*l)+dp1[i-k+1]);
}
forn(i,n) a[i]=l-a[i];
reverse(all(a));
dp2.pb(0);
forn(i,n) {
if (i<k) dp2.pb(min(2*a[i],1ll*l));
else dp2.pb(min(2*a[i],1ll*l)+dp2[i-k+1]);
}
reverse(all(dp2));
ll ans=inf;
forn(i,n+1) ans=min(ans,dp1[i]+dp2[i]);
return ans;
#undef int
}
# | 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... |