# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844357 | 2023-09-05T12:38:11 Z | matan | A Plus B (IOI23_aplusb) | C++17 | 0 ms | 0 KB |
#include <vector> #include <algorithm> #include <queue> std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B){ std::vector<int> C(N); std::vector<int> CC_index(N, 0); std::vector<int> C(N); std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> pq; for (int i = 0; i < N; i++) { pq.push({A[i] + B[0], 0}); } int k = 0; while (k < N) { auto [sum, j] = pq.top(); pq.pop(); C[k++] = sum; if (j < N - 1) { pq.push({sum - B[j] + B[j + 1], j + 1}); } } return C; }