| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 114 | 38 | 32 | 29.907% |
Borcsa has two arrays, each of them containing $N$ non-negative integers.
The numbers in the first array are $A[0],A[1], \dots ,A[N - 1]$ and the numbers in the second array are $B[0],B[1], \dots ,B[N - 1]$. The numbers in both arrays are in increasing order, that is,
Borcsa really likes arithmetical addition, so for each $i$ from 0ドル$ to $N - 1$ and for each $j$ from 0ドル$ to $N - 1,ドル inclusive, she computed the sum $A[i] + B[j]$.
Let array $C$ contain all $N^2$ sums computed by Borcsa, sorted in increasing order. Your task is to find the first $N$ values in $C$.
You should implement the following procedure:
int[] smallest_sums(int N, int[] A, int[] B)
Consider the following call:
smallest_sums(2, [0, 2], [1, 4])
In this case, $N = 2$. There are $N^2 = 4$ sums computed by Borcsa:
Array $C$ contains these sums sorted in increasing order, that is, $C = [1, 3, 4, 6]$. The $N = 2$ smallest elements in C are 1ドル$ and 3ドル$. Therefore, the procedure should return the array $[1, 3]$.
Consider the following call:
smallest_sums(3, [0, 2, 2], [3, 5, 6])
The 9ドル$ pairwise sums (in increasing order) are 3,ドル 5, 5, 5, 6, 7, 7, 8, 8$. The procedure should return the 3ドル$ smallest sums, that is, the array $[3, 5, 5]$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $N = 1$ |
| 2 | 20 | $N ≤ 100$ |
| 3 | 30 | $N ≤ 2,500円$ |
| 4 | 40 | No additional constraints. |
The sample grader reads the input in the following format:
Let the elements of the array returned by smallest_sums be $c[0], c[1], \dots , c[n - 1]$ for some nonnegative $n$. The output of the sample grader is in the following format:
C++17, C++20, C++17 (Clang), C++20 (Clang)