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 <algorithm>
#include <map>
#include <iostream>
#define INF 1'000'000'000'000'000'000
#define ABS(a) ((a) > 0 ? (a) : -(a))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
long long delivery(int N, int K, int L, int p[])
{
long long best = INF;
for (int i = 0; i < K; ++i)
{
long long sum = 0;
long long pos = i;
sum += p[i] + MIN(p[i], L - p[i]);
while (pos < N-1)
{
sum += MIN(p[pos+1], L - p[pos+1]);
sum += (pos+K < N ? p[pos+K] : p[N-1]) - p[pos+1];
pos = MIN(pos+K, N-1);
sum += MIN(p[pos], L - p[pos]);
}
best = MIN(best, sum);
}
return best;
}
# | 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... |