제출 #123671

#제출 시각아이디문제언어결과실행 시간메모리
123671dragonslayerit선물상자 (IOI15_boxes)C++14
100 / 100
604 ms293856 KiB
#include "boxes.h" #include <algorithm> #include <cstdio> long long prefix[10000002]; long long suffix[10000002]; long long delivery(int N, int K, int L, int p[]) { for(int i=1;i<=N;i++){ prefix[i]=((i>=K)?prefix[i-K]:0)+2*p[i-1]; } for(int i=N;i>=1;i--){ suffix[i]=((i+K<=N+1)?suffix[i+K]:0)+2*(L-p[i-1]); } long long ans=1e18; for(int i=1;i<=N+1;i++){ ans=std::min(ans,prefix[i-1]+suffix[i]); } for(int i=1;i+K<=N+1;i++){ ans=std::min(ans,prefix[i-1]+suffix[i+K]+L); } 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...