#14. 数组元素条件替换

    ID: 14 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp1条件结构顺序结构

数组元素条件替换

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 33, 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 33 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 11, and the last element is 33. Since 33 is larger, all elements are set to 33, resulting in [3, 3, 3]. Sample 2: The array is [11 5 9]. The first element is 1111, and the last element is 99. Since 1111 is larger, all elements are set to 1111, resulting in [11, 11, 11]. Sample 3: The array is [2 11 3]. The first element is 22, and the last element is 33. Since 33 is larger, all elements are set to 33, resulting in [3, 3, 3].

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.