#include <bits/stdc++.h>
using namespace std;
vector <int> smallest_sums (int N, vector <int> A, vector <int> B) {
priority_queue < pair <int, pair <int, int>> > kolejka;
set <pair <int, int> > secik;
vector <int> C(N);
kolejka.push({(-1)*(A[0]+B[0]), {0, 0}});
for (int i = 0; i<N; i++) {
C[i] = (-1)*kolejka.top().first;
int y = kolejka.top().second.first;
int x = kolejka.top().second.second;
if (y+1 < N && secik.find({y+1, x}) == secik.end()) {
kolejka.push({(-1)*(A[y+1]+B[x]), {y+1,x}} );
secik.insert({y+1, x});
}
if (x+1 < N && secik.find({y, x+1}) == secik.end()) {
kolejka.push({(-1)*(A[y]+B[x+1]), {y, x+1}});
secik.insert({y, x+1});
}
}
return C;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |