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"
#define INF 1000000000000000000LL
long long min(long long a, long long b)
{
return (a < b)?a:b;
}
long long l[10000005];
long long r[10000005];
long long delivery(int N, int K, int L, int p[]) {
int i;
long long ans = INF;
for (i = 0; i < N; i++)
l[i] = 2LL*p[i] + ((i >= K)?l[i - K]:0);
for (i = N - 1; i >= 0; i--)
r[i] = 2LL*(L - p[i]) + ((i + K < N)?r[i + K]:0);
//no circle
for (i = 0; i <= N; i++)
ans = min(ans, (i > 0)*l[i - 1] + (i < N)*r[i]);
//one circle
for (i = 0; i + K <= N; i++)
ans = min(ans, (i > 0)*l[i - 1] + L + (i + K < N)*r[i + K]);
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... |