제출 #158347

#제출 시각아이디문제언어결과실행 시간메모리
158347johutha선물상자 (IOI15_boxes)C++14
50 / 100
62 ms29688 KiB
#include "boxes.h" #include <vector> #include <iostream> #include <algorithm> #define int long long using namespace std; int delivery(signed N, signed K, signed L, signed p[]) { vector<int> dfp_cl(N + 2); for (int i = 0; i < min(K, N); i++) { dfp_cl[i + 1] = 2*p[i]; } for (int i = K; i < N; i++) { dfp_cl[i + 1] = dfp_cl[i - K + 1] + 2*p[i]; } vector<int> dfp_cc(N + 2); for (int i = N - 1; i >= min(0, N - K); i--) { dfp_cc[i + 1] = 2*(L - p[i]); } for (int i = N - K; i >= 0; i--) { dfp_cc[i + 1] = dfp_cc[i + K + 1] + 2*(L - p[i]); } int ans = 1e12; for (int i = 0; i < N + 1; i++) { ans = min(ans, dfp_cl[i] + dfp_cc[i + 1]); if (i + K + 1 < N + 2) ans = min(ans, dfp_cl[i] + dfp_cc[i + K + 1] + 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...