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;
typedef long long int lld;
int n, k, l;
vector<int> lhalf, rhalf;
int lsize, rsize;
long long delivery(int N, int K, int L, int p[]){
lld cost = 0;
n = N; k = K; l = L;
if(n==1) return min((lld)2*p[0], (lld)2*(l-p[0]));
for(int i=0;2*p[i]<=l;i++){
lhalf.push_back(p[i]);
}
lsize = (int) lhalf.size();
for(int i=n-1;2*(l-p[i])<l;i--){
rhalf.push_back(l-p[i]);
}
rsize = (int) rhalf.size();
if(2*lhalf[lsize-1]+2*rhalf[rsize-1]<=l){
int pos_right = rsize-1;
int pos_left = lsize-1;
while(pos_right>=0){
cost += 2*rhalf[pos_right];
pos_right -= k;
}
while(pos_left>=0){
cost += 2*lhalf[pos_left];
pos_left -= k;
}
}else{
while(true){}
}
return cost;
}
# | 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... |