Submission #374690

#TimeUsernameProblemLanguageResultExecution timeMemory
374690idk321Boxes with souvenirs (IOI15_boxes)C++11
50 / 100
2086 ms29964 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll M = 1000000000000000000LL; long long delivery(int n, int k, int l, int p[]) { vector<ll> dp1(n + 1, M); dp1[0] = 0; multiset<ll> sett1; sett1.insert(0); for (int i = 0; i < n; i++) { dp1[i + 1] = *sett1.begin() + 2 * p[i]; sett1.insert(dp1[i + 1]); if (i + 1 - k >= 0) sett1.erase(sett1.find(dp1[i + 1 - k])); } vector<ll> dp2(n + 1, M); dp2[0] = 0; multiset<ll> sett2; sett2.insert(0); for (int i = 0, j = n - 1; i < n; i++, j--) { dp2[i + 1] = *sett2.begin() + 2 * (l - p[j]); sett2.insert(dp2[i + 1]); if (i + 1 - k >= 0) sett2.erase(sett2.find(dp2[i + 1 - k])); } ll res = M; for (int cycle = 0; cycle <= n; cycle++) { ll cur = l; cur *= cycle; for (int i = 0; i + (ll) cycle * k <=n; i++) { ll cur2 = cur; cur2 += dp1[i]; cur2 += dp2[n - i - cycle * k]; res = min(res, cur2); } if ((ll) cycle * k >= n) { res = min(res, cur); } } return res; } /* 5 5 100 1 3 6 53 78 */
#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...