# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1154390 | Zheing | Boxes with souvenirs (IOI15_boxes) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
ll delivery(int n, int k, int L, int X[]){
vector<long long int> positions;
for (int i = 0; i < N; i++){
positions[i] = X[i];
}
vector<long long> clockwise, anticlockwise;
for (int i = 0; i < N; i++){
long long pos = positions[i];
if (2 * pos <= L)
clockwise.push_back(pos);
else
anticlockwise.push_back(L - pos);
}
sort(clockwise.begin(), clockwise.end(), greater<long long>());
sort(anticlockwise.begin(), anticlockwise.end(), greater<long long>());
long long total_time = 0;
for (int i = 0; i < clockwise.size(); i += K){
total_time += 2 * clockwise[i];
}
for (int i = 0; i < anticlockwise.size(); i += K){
total_time += 2 * anticlockwise[i];
}
return total_time;
}