A Plus B
InterviewTime limit1sMemory limit1024 MB
Given two sorted arrays A and B of length N, output the N smallest of all N^2 pairwise sums A[i] + B[j] in increasing order.
Problem
Borcsa has two arrays, each containing non-negative integers. The first array holds , and the second holds . Both arrays are sorted in increasing order:
Borcsa computed the sum for every pair of indices and from to . Let be the list of all sums, sorted in increasing order. Find the first values of .
Constraints
- for each with
- for each with
- and are sorted in increasing order.