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;
long long delivery(int N, int K, int L, int p[]){
int m=-1;
long long ans=0;
for (int i=0;i<N;i++)if (p[i]*2<L)m=i;
for (int i=m;i>=0;i-=K)ans+=p[i]*2;
for (int i=m+1;i<N;i+=K)ans+=(L-p[i])*2;
if (m==-1||m==N-1)return ans;
for (int t=0;t<K;t++){
// printf("Case:%d\n",t);
long long ans1=0;
int l=0,r=t;
for (;;){
if (r<=m)ans1+=2*p[r];
if (l<=m&&r>m)ans1+=L;
if (l>m)ans1+=2*(L-p[l]);
// printf("l=%d r=%d ans=%d\n",l,r,ans1);
if (r==N-1)break;
l=r+1;r+=K;
if (r>N-1)r=N-1;
}
ans=min(ans,ans1);
}
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... |