Submission #1358020

#TimeUsernameProblemLanguageResultExecution timeMemory
1358020po_rag526A Plus B (IOI23_aplusb)C++20
100 / 100
73 ms13168 KiB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
vector<int> ans;
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	pq.push({A[0]+B[0],{0,0}});
	set<pair<int,int>> s;
	s.insert({0,0});
	for(int i = 1  ; i<=N ; ++i) {
		auto get = pq.top();pq.pop();
		ans.push_back(get.first);
		if(i == N) break;
		if(!s.count({get.second.first+1,get.second.second}))pq.push({A[get.second.first+1]+B[get.second.second],{get.second.first+1,get.second.second}}),s.insert({get.second.first+1,get.second.second});
		if(!s.count({get.second.first,get.second.second+1}))pq.push({A[get.second.first]+B[get.second.second+1],{get.second.first,get.second.second+1}}),s.insert({get.second.first,get.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...