This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef atom
#include "grader.cpp"
#else
#include "boxes.h"
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
const int maxn = 1e7+5;
ll dp1[maxn];
ll dp2[maxn];
int a[maxn];
long long delivery(int n, int k, int l, int p[])
{
for(int i = 1; i<= n; i++) a[i] = p[i-1];
for(int i = 1; i<= k; i++) dp1[i] = p[i];
for(int i = n; i> n-k; i--) dp2[i] = l-p[i];
for(int i = k+1; i<= n; i++) dp1[i] = p[i]+dp1[i-k];
for(int i = n-k; i>= 1; i--) dp2[i] = (l-p[i])+dp2[i+k];
ll best = 1e18;
for(int i = 0; i<= n; i++)
{
best = min(best, dp1[i]+dp2[i+1]);
}
for(int i = 1; i<= n; i++)
{
ll left = dp1[i-1];
ll right = i+k<= n?dp2[i+k]:0;
best = min(best, left+right+l);
}
return best;
return 0;
}
# | 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... |