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