# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283520 | FlashGamezzz | 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 <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include "boxes.h"
using namespace std;
long teams[10000000];
long long delivery(int N, int K, int L, int p[]) {
long n = N, k = K, len = L;
long long ans = 1000000000000000000;
for (long i = 0; i < n; i++){
teams[i] = p[i];
}
for (long i = 0; i < k && i < n; i++){
long long t = min(len, min(2*teams[i], 2*(len-teams[0])));
long l = i+1, r = i+k-1;
while (true){
if (r >= n){
if (l < n){
r = n-1;
t += min(len, min(2*teams[r], 2*(len-left[l])));
}
break;
}
t += min(len, min(2*teams[r], 2*(len-teams[l])));
l += K;
r += K;
}
ans = min(ans, t);
}
return ans;
}