Submission #1357783

#TimeUsernameProblemLanguageResultExecution timeMemory
1357783po_rag526A Plus B (IOI23_aplusb)C++20
10 / 100
0 ms344 KiB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;
struct what{
	int p1,p2,a;
	bool operator <(const what&o) {
		if(a!=o.a) return a>o.a;
		if(p1 != o.p1) return p1<o.p1;
		return p2<o.p2;
	}
};
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
	vector<int> ans;
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
	pq.push({A[0]+B[0],{0,0}});
	for(int i = 1  ; i<=N ; ++i) {
		auto get = pq.top();pq.pop();
		ans.push_back(get.first);
		if(get.second.first != N-1) pq.push({A[get.second.first+1]+B[get.second.second],{get.second.first+1,get.second.second}});
		if(get.second.second != N-1) pq.push({A[get.second.first]+B[get.second.second+1],{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...