제출 #836744

#제출 시각아이디문제언어결과실행 시간메모리
836744AbdelmagedNour선물상자 (IOI15_boxes)C++17
100 / 100
468 ms293844 KiB
#include <vector> #include <cmath> #include <algorithm> #include <numeric> #include <climits> using namespace std; //#include "grader.cpp" #include "boxes.h" long long delivery(int N, int K, int L, int p[]){ vector<long long>pre(N+1),suf(N+1); long long res=LLONG_MAX; for(int i=0;i<N;i++)pre[i+1]=2*p[i]+(i+1>=K?pre[i+1-K]:0); for(int i=N-1;i>=0;i--)suf[i]+=2*(L-p[i])+(i+K<N?suf[i+K]:0); for(int i=0;i<N;i++)res=min(res,pre[i]+suf[i]); for(int i=K-1;i<N;i++){ int l=p[i-K+1],r=p[i]; int cost=min({L,2*r,2*(L-l)}); res=min(res,cost+pre[i-K+1]+suf[i+1]); } return res; }
#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...