제출 #798556

#제출 시각아이디문제언어결과실행 시간메모리
798556HaroldVemeno선물상자 (IOI15_boxes)C++17
100 / 100
423 ms121408 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll dp[10000000]; long long delivery(int n, int k, int l, int p[]) { for(int i = 0; i < min(n, k); ++i) { dp[i] = min({2*p[i], 2*(l-p[0]), l}); } for(int i = k; i < n; ++i) { dp[i] = dp[i-k] + min({2*p[i], 2*(l-p[i-k+1]), l}); } ll res = dp[n-1]; for(int i = max(0, n-k-1); i < n-1; ++i) { res = min(res, dp[i] + min({2*p[n-1], 2*(l-p[i+1]), l})); } if(0) { for(int i = 0; i < n; ++i) { cout << dp[i] << ' '; } cout << '\n'; } 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...