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>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
int n,k,l;
int dp1[10000069],dp2[10000069];
long long delivery(int N, int K, int Li, int p[]) {
n=N;k=K;l=Li;
for (int i = 0; i < n; i++) {
if (!i) {
dp1[i]=p[0];
continue;
}
if (!(i%k)) {
dp1[i]=dp1[i-1]+p[i];
}
else {
dp1[i]=dp1[i-1]+p[i]-p[i-1];
}
}
for (int i = n-1; ~i; i--) {
if (!((n-1-i)%k)) {
dp2[i]=dp2[i+1]+l-p[i];
}
else {
dp2[i]=dp2[i+1]+p[i+1]-p[i];
}
}
int ans=dp2[0];
for (int i = 0; i < n; i++) {
ans=min(ans,dp1[i]+dp2[i+1]);
}
return ans*2;
}
# | 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... |