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;
long long delivery(int N, int K, int L, int p[]){
lld cost = 0;
n = N; k = K; l = L;
int esq = 0, dir = n-1;
while(esq<=dir){
lld cost_esq, cost_dir;
cost_esq = min(2*((lld)p[min(esq+k-1, dir)]), (lld) l);
cost_dir = min(2*((lld)(l-p[max(dir-k+1, esq)])), (lld) l);
if(cost_esq<cost_dir){
cost += cost_esq;
esq = min(esq+k-1, dir)+1;
}else{
cost += cost_dir;
dir = max(dir-k+1, esq)-1;
}
//cout << "esq: " << cost_esq << endl;
//cout << "dir: " << cost_dir << endl;
//cout << cost << endl;
}
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... |