# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
619035 | A_D | Boxes with souvenirs (IOI15_boxes) | C++14 | 703 ms | 301892 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;
const int N=1e7+10;
long long pre[N];
long long suf[N];
deque<pair<long long,long long>> deq;
long long delivery(int N, int K, int L, int p[]) {
long long ans=1e18;
deq.push_back({(int)0,(int)-1});
for(int i=0;i<N;i++){
if(deq[0].second+K<i)deq.pop_front();
long long h=p[i];
long long u=deq[0].first;
u+=h;
pre[i]=u+min(h,L-h);
deq.push_back({pre[i],i});
}
ans=pre[N-1];
deq.clear();
deq.push_back({0,N});
for(int i=N-1;i>=0;i--){
if(deq[0].second-K>i)deq.pop_front();
long long h=p[i];
long long u=deq[0].first;
u+=(L-h);
suf[i]=u+min(h,L-h);
// for(auto x:deq)cout<<x.first<<" ";cout<<"\n";
deq.push_back({suf[i],i});
}
ans=min(ans,suf[0]);
for(int i=0;i<N-1;i++){
ans=min(ans,pre[i]+suf[i+1]);
}
// for(int i=0;i<N;i++)cout<<pre[i]<<" ";cout<<"\n";
// for(int i=0;i<N;i++)cout<<suf[i]<<" ";cout<<"\n";
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... |