제출 #840490

#제출 시각아이디문제언어결과실행 시간메모리
840490ZeroCoolA Plus B (IOI23_aplusb)C++17
100 / 100
95 ms12792 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...