Submission #726454

#TimeUsernameProblemLanguageResultExecution timeMemory
726454Yell0Boxes with souvenirs (IOI15_boxes)C++17
100 / 100
561 ms284336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll delivery(int N,int K,int L,int positions[]) { vector<ll> cw(N),ccw(N); for(int i=0;i<K;++i) cw[i]=positions[i]*2; for(int i=K;i<N;++i) cw[i]=positions[i]*2+cw[i-K]; for(int i=N-1;i>N-1-K;--i) ccw[i]=(L-positions[i])*2; for(int i=N-1-K;i>=0;--i) ccw[i]=(L-positions[i])*2+ccw[i+K]; ll ans=min({cw[N-1],ccw[0],L+cw[N-1-K],L+ccw[K]}); for(int i=0;i<N-1;++i) ans=min(ans,cw[i]+ccw[i+1]); for(int i=0;i<=N-1-K;++i) ans=min(ans,L+cw[i]+ccw[i+1+K]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...