# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1171752 | anteknne | A Plus B (IOI23_aplusb) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
set<pair<int, pair<int, int>>> s;
vector<int> v;
vector<int> smallest_sums(int n, vector<int> a, vector<int> b) {
a.pb(INT_MAX/2);
b.pb(INT_MAX/2);
s.insert({a[0] + b[0], {0, 0}});
for (int i = 0; i < n; i ++) {
pair<int, pair<int, int>> x = *s.begin();
s.erase(x);
v.pb(x.st);
s.insert({a[x.nd.st + 1] + b[x.nd.nd], {x.nd.st + 1, x.nd.nd}});
s.insert({a[x.nd.st] + b[x.nd.nd + 1], {x.nd.st, x.nd.nd + 1}});
}
return v;
}
int main () {
for (auto x : smallest_sums(3, {0, 2, 2}, {3, 5, 6})) {
cout << x << " ";
}
}