제출 #840434

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