#t111. 数字替换
数字替换
Number Replacement
Problem Description
Xiaoyang has a sequence of numbers, i.e. . He wants to replace every number greater than with the maximum value of the sequence, and every number less than with the minimum value of the sequence. Please compute the resulting sequence after the replacement.
Input Format
The first line contains two positive integers , as described.
The second line contains numbers, representing the sequence .
Output Format
Output 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, , the maximum is and the minimum is . The numbers greater than are and , both replaced by the maximum ; the numbers less than are and , both replaced by the minimum ; the number equal to , which is , stays unchanged. So the resulting sequence is .
Constraints
For all data, , .