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 <bits/stdc++.h>
#define LL long long
using namespace std;
LL a[100010];
long long delivery(int N, int K, int L, int p[]) {
int n = N,k = K;
for(int i=1;i<=n;i++)
a[i] = p[i-1];
sort(a+1,a+n+1);
LL l = 1,r = n;
LL ret = 0;
for(int i=1;i<=(n+k-1)/k;i++){
LL ans1 = a[min(l+k-1,r)]*2;
LL ans2 = (L-a[max(r-k+1,l)])*2;
if(ans1<ans2){
ret += ans1;
l += k;
}
else {
ret += ans2;
r -= k;
}
}
return ret;
}
# | 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... |