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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
const int nax = 1e7 + 3;
const long long INF = 1e18;
long long other_wing[nax];
int n, k, L;
long long ans = INF;
long long delivery(int N, int K, int l, int p[]) {
n = N, k = K, L = l;
int cur = 0;
int cnt = k;
long long _time = p[0];
while(cur<n) {
--cnt;
other_wing[cur] = _time;
if(cur+1<n) {
if(cnt==0) {
_time += p[cur] * 2;
cnt = k;
}
_time += p[cur+1] - p[cur];
}
++cur;
}
ans = min(ans, _time+min(p[n-1], L-p[n-1]));
cur = n-1;
cnt = k;
_time = L-p[n-1];
while(cur>=0) {
--cnt;
if(cur==0) {
ans = min(ans, _time+min(p[0], L-p[0]));
}
if(cnt==0 && cur) {
ans = min(ans, _time + min(p[cur], L-p[cur]) + other_wing[cur-1] +
min(p[cur-1], L-p[cur-1]));
}
if(cur-1>=0) {
if(cnt==0) {
_time += 2 * min(p[cur], L-p[cur]);
cnt = k;
}
_time += p[cur] - p[cur-1];
}
--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... |