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;
using Node = array<int, 3>;
vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
vector<int> ans;
priority_queue<Node, vector<Node>, greater<Node> > pq;
pq.push({ A[0] + B[0], 0, 0 });
set<pair<int, int> > st;
for(int it=0; it<N; it++) {
auto [val, i, j] = pq.top(); pq.pop();
ans.push_back(val);
if(!st.count({ i+1, j })) {
pq.push({ A[i+1] + B[j], i+1, j });
st.insert({ i+1, j });
}
if(!st.count({ i, j+1 })) {
pq.push({ A[i] + B[j+1], i, j+1 });
st.insert({ i, j+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... |