# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1205687 | wpdmd76 | A Plus B (IOI23_aplusb) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()
#include "aplusb.h"
vector<ll> smallest_sums(int N, vector<int> a, vector<int> b) {
vector<ll> res;
int st = 0, en = 0;
priority_queue<array<ll,3>,vector<array<ll,3>>,greater<array<ll,3>>> pq;
pq.push({a[st] + b[en], st, en});
while(true){
auto[x, i, j] = pq.top();
pq.pop();
res.push_back(x);
pq.push({a[i + 1] + b[j], i + 1, j});
pq.push({a[i] + b[j + 1], i, j + 1});
if(res.size() == N) break;
}
return {res};
}