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 <vector>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int delivery(signed N, signed K, signed L, signed p[])
{
vector<int> dfp_cl(N + 2);
for (int i = 0; i < min(K, N); i++)
{
dfp_cl[i + 1] = 2*p[i];
}
for (int i = K; i < N; i++)
{
dfp_cl[i + 1] = dfp_cl[i - K + 1] + 2*p[i];
}
vector<int> dfp_cc(N + 2);
for (int i = N - 1; i >= min(0, N - K); i--)
{
dfp_cc[i + 1] = 2*(L - p[i]);
}
for (int i = N - K; i >= 0; i--)
{
dfp_cc[i + 1] = dfp_cc[i + K + 1] + 2*(L - p[i]);
}
int ans = 1e12;
for (int i = 0; i < N + 1; i++)
{
ans = min(ans, dfp_cl[i] + dfp_cc[i + 1]);
if (i + K + 1 < N + 2) ans = min(ans, dfp_cl[i] + dfp_cc[i + K + 1] + L);
}
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... |