# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802319 | Liudas | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 260 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>
#include "boxes.h"
using namespace std;
vector<long long> get_cost(int N, int K, int L, int pos[]){
vector<long long> arr(N, 0);
for(int i = 0; i < N; i ++){
arr[i] += pos[i];
if(i >= K)arr[i] += arr[i-K] + pos[i-K];
}
return arr;
}
long long delivery(int N, int K, int L, int pos[]){
int z = count(pos, pos+N, 0);
vector<long long> l, r;
l = get_cost(N, K, L, pos);
long long ans = min(l.back()+pos[N-1], l.back()+L-pos[N-1]);
reverse(pos + z, pos + N);
for(int i = 0; i < N; i ++){
pos[i] = (pos[i] ? L - pos[i] : pos[i]);
}
r = get_cost(N, K, L, pos);
ans = min({ans, r.back()+pos[N-1], r.back()-pos[N-1]+L});
reverse(pos + z, pos + N);
reverse(r.begin(), r.end());
for(int i = 0; i < N; i ++){
pos[i] = (pos[i] ? L - pos[i] : pos[i]);
}
for(int i = 0; i < N - 1; i ++){
ans = min(ans, l[i]+r[i+1]+min(L-pos[i],pos[i])+min(L-pos[i+1], pos[i+1]));
}
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... |