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 "aplusb.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
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> ans;
set<pair<int, int>> vis;
pq.push({A[0] + B[0], {0, 0}});
for (int i = 0;i<n;i++){
auto h = pq.top();
pq.pop();
ans.push_back(h.first);
if (!vis.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}});
vis.insert({h.second.first + 1, h.second.second});
}
if (!vis.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}});
vis.insert({h.second.first, h.second.second + 1});
}
}
return ans;
}
# | 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... |