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 <bits/stdc++.h>
#include "aplusb.h"
using namespace std;
vector<int> smallest_sums(int n, vector<int> a, vector<int> b) {
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<>> pq;
vector<int> out(n);
set<pair<int, int>> visited;
int f = 0;
pq.push({a[0] + b[0], {0, 0}});
for (int i = 0; i < n; ++i){
auto h = pq.top();
pq.pop();
out[f] = h.first;
f += 1;
if (!visited.count({h.second.first + 1, h.second.second})){
pq.push({a[h.second.first + 1] + b[h.second.second], {h.second.first + 1, h.second.second}});
visited.insert({h.second.first + 1, h.second.second});
}
if (!visited.count({h.second.first, h.second.second + 1})){
pq.push({a[h.second.first] + b[h.second.second + 1], {h.second.first, h.second.second + 1}});
visited.insert({h.second.first, h.second.second + 1});
}
}
return out;
}
# | 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... |