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"
using namespace std;
#include<bits/stdc++.h>
long long delivery(int n, int k, int l, int p[]) {
int left;
int i = 0;
while(p[i] == 0)i++;
int t = -1;
long long ans = (long long)(n + k - i - 1) / k * l;
i += k - 1;
while(i < n && p[i] * 2 < l){
if(i == t){
break;
}
ans = ans - l + p[i] * 2;
t = max(i + k, n - 1);
i = t;
}
left = n - i;
t = -1;
int j = n - k;
while(l < p[j] * 2){
if(t == j){
break;
}
ans = ans + l - p[j] * 2;
t = max(0 , j - k);
left -=t - j;
j = t;
}
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... |