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"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
using namespace std;
long long delivery(int n, int k, int l, int p[]) {
ll ans = 2e18;
vl clockwise(n+5,0);
for(ll i = 0;i < n;i++){
if(i < k){
clockwise[i + 1] = 2 * p[i];
}else{
clockwise[i + 1] = clockwise[i + 1 - k] + (2 * p[i]);
}
}
vl anticlockwise(n+5, 0);
for(ll i = n - 1;i >= 0;i--){
if(i >= n - k + 1){
anticlockwise[i + 1] = 2 * (l - p[i]);
}else{
anticlockwise[i + 1] = anticlockwise[i + 1 + k] + (2 * (l - p[i]));
}
}
for(ll i = 0;i <= n;i++){
ans = min(ans,clockwise[i] + anticlockwise[i + 1]);
}
for(ll i = 0;i <=n-k;i++){
ans = min(ans,clockwise[i] + anticlockwise[i + 1 + k] + l);
}
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... |