제출 #567894

#제출 시각아이디문제언어결과실행 시간메모리
567894Trisanu_Das선물상자 (IOI15_boxes)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int delivery(int n, int k, int l, int a[]){ int dp1[n + 1], dp2[n + 1], pos[n + 1]; dp1[0] = 0; dp2[0] = 0; for(int i = 0; i < n; i++) pos[i + 1] = a[i]; sort(a + 1, a + n + 1); for(int i = 1; i <= n ; i++){ dp1[i] = dp1[max(0, i - k)] + 2 * pos[i]; } for(int i = 1; i <= n ; i++){ dp2[i] = 2 * (l - pos[i]) + dp2[min(n + 1, i + k)]; } int ans = 1e9; for (int i = 1;i < n + 1; i++) ans = min(ans, dp1[i - 1] + dp2[i]); for (int i = k;i <= n; i++) ans = min(ans, dp1[i - k] + dp2[i + 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...