This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// M
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
const int N = 10000007;
int n, k, L, A[N];
ll P[N], S[N];
long long delivery(int _n, int _k, int _L, int _p[])
{
k = _k; L = _L;
for (int i = 0; i < _n; i ++)
if (_p[i])
A[++ n] = _p[i];
ll Mn = (n + k - 1) / k * (ll)L;
for (int i = 1; i <= n; i ++)
{
if (i >= k)
P[i] = P[i - k];
P[i] += A[i];
}
for (int i = n; i; i --)
{
if (i + k <= n)
S[i] = S[i + k];
S[i] += L - A[i];
}
for (int i = 0; i <= n; i ++)
{
Mn = min(Mn, (P[i] + S[i + 1]) * 2LL);
ll s = 0;
if (i + k + 1 <= n)
s = S[i + k + 1];
Mn = min(Mn, (P[i] + s) * 2LL + L);
}
return Mn;
}
# | 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... |