# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
393211 | peuch | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 208 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 "boxes.h"
#include<bits/stdc++.h>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
long long l[N], r[N];
long long n = N;
long long k = K;
for(int i = 0; i < N; i++){
l[i] = 2 * p[i];
if(i >= k) l[i] += l[i - k];
}
for(int i = N - 1; i >= 0; i--){
r[i] = 2 * (L - p[i]);
if(i + k < N) r[i] += r[i + k];
}
long long ans = n * L;
for(int i = 0; i < N - 1; i++){
ans = min(ans, l[i] + r[i + 1]);
long long aux = L;
int left = i - 1;
int right = i + k;
if(left >= 0) aux += l[left];
if(right < N) aux += r[right];
ans = min(ans, aux);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |