#14. 数组元素条件替换
数组元素条件替换
Array Element Replacement
Background
Congcong is organizing a list of three numbers. He wants all numbers in the list to become the maximum of its first or last element.
Problem Description
Given an array of integers of length , determine which is larger, the first or the last element in the array, and set all other elements to be that value. Return the modified array.
Input Format
Input is given from standard input in the following format.
An array containing integers.
Output Format
Output is printed to standard output in the following format.
The modified array.
Sample
[1 2 3]
[3, 3, 3]
[11 5 9]
[11, 11, 11]
[2 11 3]
[3, 3, 3]
Sample Explanation
Sample 1: The array is [1 2 3]. The first element is , and the last element is . Since is larger, all elements are set to , resulting in [3, 3, 3].
Sample 2: The array is [11 5 9]. The first element is , and the last element is . Since is larger, all elements are set to , resulting in [11, 11, 11].
Sample 3: The array is [2 11 3]. The first element is , and the last element is . Since is larger, all elements are set to , resulting in [3, 3, 3].
Constraints
Time limit: second, Memory limit: KiB for each test case.