#K14121. Rearrange Sequence for Sum

    ID: 24065 Type: Default 1000ms 256MiB

Rearrange Sequence for Sum

Rearrange Sequence for Sum

You are given two sequences of integers, A and B, each of length \(n\), and an integer \(k\). Your task is to determine whether it is possible to rearrange the sequence B into B' such that for every index \(i\) the following equation holds:

\(A[i] + B'[i] = k\)

If such a rearrangement exists, print YES in the first line and the rearranged sequence B' (with the numbers separated by spaces) in the second line. Otherwise, print NO.

inputFormat

The input is read from stdin as follows:

n k
A[0] A[1] ... A[n-1]
B[0] B[1] ... B[n-1]

For example:

3 5
1 2 3
4 3 2

outputFormat

Output the answer to stdout. If a valid rearrangement exists, print YES on the first line and a line with the rearranged sequence B' (n space-separated integers) on the second line. Otherwise, print NO.## sample

3 5
1 2 3
4 3 2
YES

4 3 2

</p>