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;
using ll = long long;
ll delivery(int N, int K, int L, int p[]) {
int s = 0, e = N - 1, k = K;
while(s <= e && p[s] == 0) ++s;
if(s > e) return 0;
ll t = 0;
while(s <= e){
int ans1 = p[min(s+k-1, e)] * 2;
int ans2 = (L-p[max(s, e-k+1)]) * 2;
if(ans1 < ans2){
s = min(s+k-1, e) + 1;
t += ans1;
}else{
e = max(s, e-k+1) - 1;
t += ans2;
}
}
return t;
}
# | 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... |