이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |