# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015361 | amine_aroua | 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>
using namespace std;
#define intt long long
multiset<int> pos;
int l;
intt minDist(int i , int j)
{
return min(abs(i - j) , l - abs(i - j));
}
int comb(int it1 , int it2 , int p)
{
if(minDist(p , it1) > minDist(p , it2))
return it2;
return it1;
}
long long delivery(int N, int K, int L, vector<int> p)
{
l = L;
for(int i = 0 ; i < N ; i++)
pos.insert(p[i]);
int beg = 0;
intt ans = 0;
while(!pos.empty())
{
int cnt = K;
ans+= minDist(beg , 0);
beg = 0;
while(!pos.empty() && cnt--)
{