Submission #213304

#TimeUsernameProblemLanguageResultExecution timeMemory
213304arman_ferdousBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
588 ms293884 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long delivery(int n, int k, int l, int p[]) { ll dp1[n + 1], dp2[n + 1]; dp1[0] = dp2[0] = 0; for(int i = 1; i <= n; i++) { dp1[i] = 2ll * p[i - 1] + (i - k >= 0 ? dp1[i - k] : 0); dp2[i] = 2ll * (l - p[n - i]) + (i - k >= 0 ? dp2[i - k] : 0); } ll ans = 1e18; for(int i = 0; i <= n; i++) { ans = min(ans, dp1[i] + dp2[n - i]); if(n - i - k >= 0) ans = min(ans, dp1[i] + dp2[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...