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>
using namespace std;
#define N 10000005
long long dp1[N],dp2[N],ans=1e18;
long long delivery(int n,int k,int l,int pos[N]){
int i;
sort(pos,pos+n);
for(i=0;i<n;i++){
if(i>=k)dp1[i]=dp1[i-k]+2*pos[i];
else dp1[i]=2*pos[i];
}
for(i=n-1;i>=0;i--){
if(i+k<n)dp2[i]=dp2[i+k]+2*(l-pos[i]);
else dp2[i]=2*(l-pos[i]);
}
for(i=0;i+1<n;i++)ans=min(ans,dp1[i]+dp2[i+1]);
for(i=0;i+k+1<n;i++)ans=min(ans,dp1[i]+dp2[i+k+1]+l);
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... |