#t111. 数字替换

数字替换

Number Replacement

Problem Description

Xiaoyang has a sequence AA of nn numbers, i.e. A=[a1,a2,…,an]A=[a_1,a_2,\ldots,a_n]. He wants to replace every number greater than kk with the maximum value of the sequence, and every number less than kk with the minimum value of the sequence. Please compute the resulting sequence after the replacement.

Input Format

The first line contains two positive integers n,kn, k, as described.

The second line contains nn numbers, representing the sequence AA.

Output Format

Output nn integers, representing the result after replacement.

Sample Input

5 0
-2 -1 0 1 2

Sample Output

-2 -2 0 2 2

Sample Explanation

In the sample, A=[−2,−1,0,1,2]A=[-2,-1,0,1,2], the maximum is 22 and the minimum is −2-2. The numbers greater than k=0k=0 are 11 and 22, both replaced by the maximum 22; the numbers less than k=0k=0 are −2-2 and −1-1, both replaced by the minimum −2-2; the number equal to kk, which is 00, stays unchanged. So the resulting sequence is [−2,−2,0,2,2][-2,-2,0,2,2].

Constraints

For all data, 1≤n≤1051 \le n \le 10^5, ∣k∣,∣ai∣≤105|k|, |a_i| \le 10^5.