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 ll long long
using namespace std;
ll delivery(int N, int K, int M, int p[])
{
ll L[N + 1], R[N + 1];
L[0] = 0;
for (int i = 1; i <= N; i++)
{
L[i] = L[(i - 1) / K * K] + p[i - 1] * 2;
}
R[0] = 0;
for (int i = 1; i <= N; i++)
{
R[i] = R[(i - 1) / K * K] + (M - p[N - i]) * 2;
}
ll ans = 1e18;
for (int i = 0; i <= N; i++)
{
ans = min(ans, L[i] + R[N - i]);
if(N - i - K >= 0){
ans = min(ans, L[i] + R[N - i - K] + M);
}
}
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... |