Submission #537828

#TimeUsernameProblemLanguageResultExecution timeMemory
537828timreizinBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms340 KiB
#include "boxes.h" #include <vector> using namespace std; using ll = long long; ll compute(vector<ll> &a, int k) { ll res = 0; for (int i = (int)a.size() - 1; i >= 0; i -= k) res += a[i] * 2; return res; } long long delivery(int n, int k, int l, int P[]) { vector<ll> teams(n); for (int i = 0; i < n; ++i) teams[i] = P[i]; vector<ll> side, left; while (!teams.empty() && l - teams.back() < teams.back()) { side.push_back(l - teams.back()); teams.pop_back(); } ll minRes = compute(teams, k) + compute(side, k); for (int i = 0; i < k && !side.empty(); ++i) { left.push_back(side.back()); side.pop_back(); } for (int i = 0; i <= k; ++i) { minRes = min(minRes, compute(teams, k) + compute(side, k) + l); if (!teams.empty()) teams.pop_back(); if (!left.empty()) { side.push_back(left.back()); left.pop_back(); } } return minRes; }
#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...