| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1316121 | khanhphucscratch | Boxes with souvenirs (IOI15_boxes) | C++20 | 0 ms | 0 KiB |
#include "boxes.h"
#include<bits/stdc++.h>
#define int long long
using namespace std;
int delivery(int n, int k, int len, int p[]) {
int l = 0, r = n-1;
int ans = 0;
while(l <= r){
if(r-l+1 <= k){
ans += 2*min(len-p[l], p[r]);
r = -1;
}
else{
if(len-p[r-k+1] < p[l+k-1]){
ans += 2*(len-p[r-k+1]); r -= k;
}
else{
ans += 2*p[l+k-1]; l += k;
}
}
}
return ans;
}
