제출 #484746

#제출 시각아이디문제언어결과실행 시간메모리
484746imachug선물상자 (IOI15_boxes)C++17
100 / 100
571 ms293508 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int l, int p[]) { vector<long long> dp_left(n + 1, 1e18); dp_left[0] = 0; for(int i = 1; i <= n; i++) { dp_left[i] = dp_left[max(0, i - k)] + 2 * p[i - 1]; } vector<long long> dp_right(n + 1, 1e18); dp_right[n] = 0; for(int i = n - 1; i >= 0; i--) { dp_right[i] = dp_right[min(n, i + k)] + 2 * (l - p[i]); } long long ans = 1e18; for(int i = 0; i <= n; i++) { ans = min(ans, dp_left[i] + dp_right[i]); ans = min(ans, dp_left[i] + dp_right[min(n, 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...