#include "boxes.h"
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
using namespace std;
const int INF = numeric_limits<int>::max()/2;
long long delivery(int32_t n, int32_t k, int32_t L, int32_t p[]) {
int mi = INF;
for(int s = 0; s < k; s++){
int c = 0;
bool f = false;
if(p[0] <= L/2 && p[s] > L/2){
c += L;
f = true;
}else if (p[0] <= L/2){
c += 2*p[s];
}else{
c += 2*(L-p[s]);
}
for(int i = s+1; i < n; i += k){
if(p[i] <= L/2 && p[min(i+k,n-1LL)] > L/2){
c += L;
f = true;
}else if (p[i] <= L/2){
c += 2*p[min(i+k,n-1LL)];
}else{
c += 2*(L-p[min(i+k,n-1LL)]);
}
}
mi = min(mi, c);
}
return mi;
}
# | 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... |