This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define taskname ""
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifndef LOCAL
#define cerr \
if (0) \
cerr
#endif
const bool multitest = 0;
const int MAXN = 1e7 + 5;
int pos[MAXN];
long long delivery(int N, int K, int L, int p[])
{
vector<ll> lt(N + 3), rt(N + 3);
for (int i = 1; i <= N; i++)
{
if (i - K >= 0)
{
lt[i] = lt[i - K] + p[i - 1] * 2;
rt[i] = rt[i - K] + ((L - p[N - i]) * 2);
}
else
{
lt[i] = p[i - 1] * 2;
rt[i] = ((L - p[N - i]) * 2);
}
}
// for (int i = 1; i <= N; i++)
// cout << lt[i] << ' ';
// cout << endl;
// for (int i = 1; i <= N; i++)
// cout << rt[i] << ' ';
// cout << endl;
ll ans = 1e18;
for (int i = 1; i <= N; i++)
{
ans = min(ans, lt[i] + rt[N - i]);
}
for (int i = K; i <= N; i++)
{
ans = min(ans, lt[i - K] + rt[N - i - 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... |