#30. 数组首尾中最大值

    ID: 30 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp1条件结构数学基础

数组首尾中最大值

Max of First, Last, and Middle

Background

Congcong is learning basic array operations. He encountered a problem where he needs to find the largest element among specific positions in a given array.

Problem Description

Given an array of integers of odd length, examine the first, last, and middle values in the array and return the largest among them. The array length will be at least 11.

Input Format

Input is given from standard input in the following format.

An array of integers, e.g., [1 2 3]. Elements are space-separated.

Output Format

Output is printed to standard output in the following format.

An integer, representing the maximum value among the first, last, and middle elements.

Sample

[1 2 3]
3
[1 5 3]
5
[5 2 3]
5

Sample Explanation

For Sample 1, the array is [1 2 3]. The first element is 11, the last element is 33, and the middle element is 22. The maximum value among them is 33. For Sample 2, the array is [1 5 3]. The first element is 11, the last element is 33, and the middle element is 55. The maximum value among them is 55. For Sample 3, the array is [5 2 3]. The first element is 55, the last element is 33, and the middle element is 22. The maximum value among them is 55.

Constraints

Time limit: 11 second. Memory limit: 11 MiB for each test case.