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"
typedef long long lint;
const int MAX = 1e7+10;
inline lint _min(lint a, lint b){ return a<b ? a : b; }
lint A[MAX], B[MAX];
lint delivery(int n, int k, int L, int p[]) {
for(int i=1; i<=n; i++) A[i] = (i-k>=0 ? A[i-k] : 0) + p[i-1] + _min(p[i-1], L-p[i-1]);
for(int i=n; i>=1; i--) B[i] = (i+k<=n+1 ? B[i+k] : 0) + L-p[i-1] + _min(p[i-1], L-p[i-1]);
lint ans = 2e18;
for(int i=0; i<=n; i++) ans = _min(ans, A[i]+B[i+1]);
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... |