아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

A Plus B

시간 제한1초메모리 제한1024 MB

요약
정렬된 두 배열의 모든 짝 합 N^2개 중에서 가장 작은 N개를 찾는다.
난이도

보통10점 중 7점

유형
힙, 투 포인터, 정렬
정답자
아직 제출이 없습니다

문제

Borcsa has two arrays, each of them containing NN non-negative integers.

The numbers in the first array are A\[0],A\[1],…,A\[N−1]A\[0],A\[1], \dots ,A\[N - 1] and the numbers in the second array are B\[0],B\[1],…,B\[N−1]B\[0],B\[1], \dots ,B\[N - 1]. The numbers in both arrays are in increasing order, that is,

  • A\[0]≤A\[1]≤⋯≤A\[N−1]A\[0] ≤ A\[1] ≤ \dots ≤ A\[N - 1], and
  • B\[0]≤B\[1]≤…≤B\[N−1]B\[0] ≤ B\[1] ≤ … ≤ B\[N - 1].

Borcsa really likes arithmetical addition, so for each ii from 00 to N−1N - 1 and for each jj from 00 to N−1N - 1, inclusive, she computed the sum A\[i]+B\[j]A\[i] + B\[j].

Let array CC contain all N2N^2 sums computed by Borcsa, sorted in increasing order. Your task is to find the first NN values in CC.

제한

  • 1≤N≤100,0001 ≤ N ≤ 100\\,000
  • 0≤A\[i]≤1090 ≤ A\[i] ≤ 10^9 (for each ii such that 0≤i<N0 ≤ i < N)
  • 0≤B\[i]≤1090 ≤ B\[i] ≤ 10^9 (for each ii such that 0≤i<N0 ≤ i < N)
  • AA and BB are sorted in increasing order.

예제

이 문제는 공개된 예제가 없습니다.