# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419154 | LouayFarah | 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;
int delivery(int n, int k, int l, int positions[])
{
if(k==1)
{
int res = 0;
for(int i = 0; i<n; i++)
{
if(positions[i]>l/2)
{
res+=2*(l-positions[i]);
}
else
{
res+=2*(positions[i]);
}
}
return res;
}
else if(k==n)
{
long long a = 0, b = 0, c = 0, d = 1e18;
a = l;
b = 2*positions[n-1];
c = 2*(l - positions[0]);
long long left = -1, right = 0;
for(int i = 0; i<n; i++)
{
if(positions[i]>=l/2)
{
if(i>0)
{
left = positions[i];
right = positions[i-1];
break;
}
else
break;
}
}
if(left!=-1)
d = 2*(l - left) + 2*right;
return min(min(a,b), min(c, d));
}
else
{
}
}