This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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::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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |