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;
long long delivery(int N, int K, int L, int p[]) {
long long ans;
ans = 1LL * 1e18 + 7;
for (int i = 0; i < N; i++)
{
ll cur = 0;
if (p[i] > L / 2)
break;
for (int j = i; j >= 0; j -= K)
{
if (p[j] <= L / 2)
cur += (p[j] * 2);
else
{
if (j - K + 1 >= 0)
{
cur += min((L - p[j - K + 1]) * 2, L);
}
else
{
if (p[0] > L / 2)
cur += min((L - p[0]) * 2, L);
else
cur += L;
}
}
}
for (int j = i + 1; j < N; j += K)
{
if (p[j] > L / 2)
{
cur += ((L - p[j]) * 2);
}
else
{
if (j + K - 1 < N)
{
cur += min(p[j + K - 1] * 2, L);
}
else
{
if (p[N - 1] <= L / 2)
cur += min(p[N - 1] * 2, L);
else
cur += L;
}
}
}
ans = min(ans, cur);
}
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... |