Submission #213269

#TimeUsernameProblemLanguageResultExecution timeMemory
213269arman_ferdousBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
5 ms384 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e7+10; int n, k; ll l; ll dp1[N], dp2[N]; long long delivery(int _n, int _k, int _l, int p[]) { n = _n, k = _k, l = _l; for(int i = 0; i < n; i++) { if(i < k) dp1[i] = 2ll * p[i]; else dp1[i] = 2ll * p[i] + dp1[i - k]; } for(int i = n - 1; i >= 0; i--) { if(n - 1 < i + k) dp2[i] = 2ll * (p[i] == 0 ? 0 : l - p[i]); else dp2[i] = 2ll * (p[i] == 0 ? 0 : l - p[i]) + dp2[i + k]; } ll ans = min(dp1[n - 1], dp2[0]); for(int i = 0; i + 1 < n; i++) ans = min(ans, dp1[i] + dp2[i + 1]); for(int i = 1; i + k < n; i++) { ll one = dp1[i - 1]; ll two = dp2[i + k]; ans = min(ans, l + one + two); } 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...