| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 31210 | top34051 | 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 "boxes.h"
#include<bits/stdc++.h>
using namespace std;
#define maxn 10000005
long long L[maxn], R[maxn];
long long delivery(int N, int K, int len, int p[]) {
int i;
long long ans;
for(i=0;i<N;i++) L[i] = ((i-K>=0) ? L[i-K] : 0LL) + p[i]*2;
for(i=N-1;i>=0;i--) R[i] = ((i+K<N) ? R[i+K] : 0LL) + (len-p[i])*2;
ans = L[N-1];
for(i=0;i<N;i++) ans = min(ans,L[i]+R[i+1]);
for(i=-1;i<N;i++) ans = min(ans,L[i]+R[i+k+1]+len);
return ans;
}
