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;
const long long INF = 1e18;
long long delivery(int N, int K, int L, int p[])
{
long long rez=INF;
int pozle=0,pozri=N-1;
int ramase=0;
while(p[pozle]==0)
{
pozle++;
ramase++;
}
long long cur=0;
for(int cnt=(N-1)/K+1;cnt>=0;cnt--)
{
while(ramase < N - cnt*K)
{
int d = min(K, N - cnt*K - ramase);
if(p[pozle+d-1] <= L - p[pozri-d+1])
{
cur += p[pozle+d-1]*2;
pozle += d;
}
else
{
cur += (L - p[pozri-d+1])*2;
pozri -= d;
}
ramase += d;
}
rez = min(rez, 1LL*cnt*L + cur);
}
return rez;
}
/*
3 2 8
1 2 5
output: 10
*/
# | 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... |