# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589846 | FatihSolak | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 308 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[]) {
vector<int> a,b;
for(int i = 0;i<n;i++){
if(2*p[i] <= l){
a.push_back(p[i]);
}
}
for(int i = n-1;i>=0;i--){
if(2*(l-p[i]) < l){
b.push_back(p[i]);
}
}
vector<long long> dpa(a.size(),0),dpb(b.size(),0);
for(int i = 0;i<a.size();i++){
dpa[i] = 2 * a[i];
if(i - k >= 0){
dpa[i] += dpa[i-k];
}
}
for(int i = 0;i<b.size();i++){
dpb[i] = 2 * (l-b[i]);
if(i - k >= 0){
dpb[i] += dpb[i-k];
}
}
if(b.empty())return dpa[a.size()-1];
if(a.empty())return dpb[b.size()-1];
long long ans = dpa[a.size()-1] + dpb[b.size()-1];
for(int i = max(0,(int)a.size()-k);i<a.size();i++){
ans = min(ans,dpa[i] + dpb[b.size()-1 - (k-(a.size() - i - 1))] + l);
}
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... |