#include<vector>
#include<set>
using namespace std;
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
vector<int> ans;
int ans_n = 0;
set<pair<int, pair<int, int>>> cands;
for (int i = 0 ; i < N; ++i) {
cands.insert({A[i] + B[0], {i, 0}});
}
while (ans_n < N*N) {
auto cur = cands.begin();
ans.push_back(cur->first);
ans_n++;
int i = cur->second.first;
int j = cur->second.second;
cands.erase(cur);
if (j+1 < N) {
cands.insert({A[i] + B[j+1], {i,j+1}});
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
1st lines differ - expected: 2 tokens, found 4 tokens |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
1st lines differ - expected: 2 tokens, found 4 tokens |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
1st lines differ - expected: 2 tokens, found 4 tokens |
6 |
Halted |
0 ms |
0 KB |
- |