# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154117 | mhy908 | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 0 KiB |
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 F first
#define S second
#define pb push_back
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
LL dp2[10000010], dp[10000010], arr[10000010], ans=llinf;
LL delivery(int n, int k, int l, int p[]) {
for(int i=0; i<n; i++)
arr[i+1]=p[i];
for(int i=1; i<=n; i++)
dp[i]=dp[max(0, i-k)]+2*arr[i];
for(int i=n; i>0; i--)
dp2[i]=dp2[min(n+1, i+k)]+2*(l-arr[i]);
for(int i=0; i<=n; i++)ans=min(ans, dp[i]+dp2[i+1]);
for(int i=0; i<=n-k; i++)ans=min(ans, dp[i]+dp2[i+k+1]+L);
return ans;
}