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 ll;
long long delivery(int N, int K, int L, int p[]) {
ll ans=0;
int l=0,r=N-1,aux,in;
sort(p,p+N);
for (;l<N;l+=K) {
aux = min(l+K-1,N-1);
if (p[aux]>L/2 || p[l]>L/2) break;
ans += min({L,2*p[aux],2*(L-p[l])});
}
for (;r>=0;r-=K) {
aux = max(r-K+1,0);
if (p[aux]<=L/2 || p[r]<=L/2) break;
ans += min({L,2*p[r],2*(L-p[aux])});
}
for (in=l;in<=r;in++) if (p[in]>L/2) break;
in--;
if (l<r) ans += min(2*L,2*p[in] + 2*(L-p[in+1]));
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... |