Submission #127952

#TimeUsernameProblemLanguageResultExecution timeMemory
127952SOIVIEONEBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long dp[N+2], pd[N + 2]; int n = N, k = K, l = L; dp[0] = 0; for(int i = 1; i <= n; i ++) dp[i] = dp[max(0, i - k)] + p[i - 1] * 2ll; pd[n + 1] = 0; for(int i = n; i >= 1; i --) pd[i] = pd[min(n + 1, i + k)] + (L-p[i - 1]) * 2ll; long long ans = 1e18; for(int i = 1; i <= n; i ++) ans = min(ans, dp[i - 1] + pd[i]); for(int i = 0; i < n; i ++) { if(i + k <= n) ans = min(ans, l + dp[i] + pd[i + k + 1]); } 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...