# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107487 | pedro_sponchiado | Boxes with souvenirs (IOI15_boxes) | C++17 | 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;
const int maxn=10000010;
long long int l[maxn], r[maxn];
long long int delivery(n, cap, tam, pos){
for(int i=1; i<=n; i++){
l[i]=2*pos[i-1];
if(i>=cap+1) l[i]+=l[i-cap];
}
for(int i=1; i<=n; i++){
r[i]=2*(tam-pos[n-i]);
if(i>=cap+1) r[i]+=r[i-cap];
}
long long int resp=1123456789123456789;
for(int i=0; i<=n; i++){
resp=min(resp, l[i]+r[n-i]);
if(n-cap-i>=0) resp=min(resp, l[i]+r[n-cap-i]+tam);
}
return resp;
}