#include <bits/stdc++.h>
using namespace std;
template <class T> using v = vector<T>;
#ifdef EVAL
#define dbg(...)
#define dbg2d(...)
#else
istream &__cin = cin;
#include "../../debug.h"
__cinwrapper __cin_wrapper;
#include "../../debug.cpp"
#endif
#include "aplusb.h"
using int2 = pair<int, int>;
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
v<int> ptr(N);
priority_queue<int2, v<int2>, greater<int2>> vals;
for (int i = 0; i < N; i++) {
vals.push({A[i] + B[0], i});
}
v<int> ans;
for (int i = 0; i < N; i++) {
auto [v, p] = vals.top();
vals.pop();
ans.push_back(v);
if (++ptr[p] < N) {
vals.push({A[i] + B[ptr[p]], p});
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 3rd token, expected: '2', found: '30' |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 3rd token, expected: '2', found: '30' |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 3rd token, expected: '2', found: '30' |
8 |
Halted |
0 ms |
0 KB |
- |