# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63321 | hamzqq9 | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 0 KiB |
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>
#include "boxes.h"
using namespace std;
#define MAX 1000006
#define ll long long
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define inf 100000000000000000
long long delivery(int N, int K, int L, int P[]) {
ll ans1=0,ans2=0;
int start=0;
while(p[start]==0) start++;
for(int i=start;i<N;i+=K) {
int last=min(N-1,i+K-1);
ll cost=min(1ll*L,min(2ll*P[last],2ll*(L-P[i])));
ans1+=cost;
}
for(int i=N-1;i>=start;i-=K) {
int last=max(start,i-K+1);
ll cost=min(1ll*L,min(2ll*P[i],2ll*(L-P[last])));
ans2+=cost;
}
return min(ans1,ans2);
}