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;
typedef long long ll;
ll delivery(int N,int K,int L,int positions[]) {
vector<ll> cw(N),ccw(N);
for(int i=0;i<K;++i) cw[i]=positions[i]*2;
for(int i=K;i<N;++i) cw[i]=positions[i]*2+cw[i-K];
for(int i=N-1;i>N-1-K;--i) ccw[i]=(L-positions[i])*2;
for(int i=N-1-K;i>=0;--i) ccw[i]=(L-positions[i])*2+ccw[i+K];
ll ans=min({cw[N-1],ccw[0],L+cw[N-1-K],L+ccw[K]});
for(int i=0;i<N-1;++i) ans=min(ans,cw[i]+ccw[i+1]);
for(int i=0;i<=N-1-K;++i) ans=min(ans,L+cw[i]+ccw[i+1+K]);
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... |