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;
LL dist(LL x,LL y,LL mod){
return min((y-x+mod)%mod,(x-y+mod)%mod);
}
LL delivery(int N, int K, int L, int p[]) {
LL ans=0;
if(K==1){
for(LL i=0;i<N;i++)ans=ans+2*dist(p[i],0,L);
return ans;
}
for(LL i=0;i<N;i++){
if(i%K==0)ans+=dist(0,p[i],L);
else if(i%K==K-1){
ans+=dist(p[i],p[i-1],L);
ans+=dist(p[i],0,L);
}
else ans+=dist(p[i],p[i-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... |