# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
621960 | Deepesson | Boxes with souvenirs (IOI15_boxes) | C++17 | 2 ms | 384 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>
long long delivery(int N, int K, int L, int p[]);
using ll = long long;
ll inf = 1LL<<60LL;
long long delivery(int N, int K, int L, int p[]) {
ll dp[N+1];
for(auto&x:dp)x=inf;
dp[0]=0;
std::multiset<ll> setnob,setcob;
setnob.insert(0);
setcob.insert(2*L);
std::deque<ll> dn,dc;
dn.push_back(0);
dc.push_back(2*L);
for(int i=0;i!=N;++i){
ll custo_local = std::min((ll)L,(ll)2*p[i]);
dp[i+1]=std::min(*setnob.begin()+custo_local,*setcob.begin());
if(dn.size()==K){
setnob.erase(setnob.find(dn.front()));
dn.pop_front();
}
if(dc.size()==K){
setcob.erase(setcob.find(dc.front()));
dc.pop_front();
}
ll custo_push = 2*L-2*p[i+1];
setnob.insert(dp[i+1]);
dn.push_back(dp[i+1]);
setcob.insert(dp[i+1]+custo_push);
dc.push_back(dp[i+1]+custo_push);
}
return dp[N];
}
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... |