# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979661 | canadavid1 | A Plus B (IOI23_aplusb) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "aplusb.h"
#include <set>
#include <utility>
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
auto cmp = [&](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];};
std::set<std::pair<int,int>,decltype(cmp)> q(cmp);
std::vector<int> out;
q.emplace(0,0);
while(out.size()<N)
{
auto[a,b] = *out.begin();
out.push(A[a]+B[b]);
out.erase(out.begin());
if(a+1<N) out.emplace(a+1,b);
if(b+1<N) out.emplace(a,b+1);
}
return out;
}