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 <algorithm>
using namespace std;
long long Res1, Res2;
long long delivery(int N, int K, int L, int p[]) {
int i, s;
for(i=0 ; i<N ; i++)
if(p[i])
break;
s=i;
while(i+K-1<N && p[i+K-1]<=L/2) {
Res1+=2*p[i+K-1];
i+=K;
}
if(i<N && p[i]<=L/2) {
Res1+=L;
i+=K;
}
while(i<N) {
Res1+=2*(L-p[i]);
i+=K;
}
i=N-1;
while(i-K+1>=s && p[i-K+1]>=L/2) {
Res2+=2*(L-p[i-K+1]);
i-=K;
}
if(i>=s && p[i]>=L/2) {
Res2+=L;
i-=K;
}
while(i>=s) {
Res2+=2*p[i];
i-=K;
}
return min(Res1,Res2);
return 0;
}
# | 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... |