#C11586. Mountain Array Verification
Mountain Array Verification
Mountain Array Verification
In this problem, you are given several arrays of integers. Your task is to determine whether each array is a mountain array.
A mountain array is defined as an array with length at least 3 such that there exists an index \( i \) (with \( 1 < i < n \)) satisfying:
\( a_1 < a_2 < \cdots a_{i+1} > \cdots > a_n \)
The input consists of multiple lines, each representing an array with space-separated integers. A special line containing only -1
is used to indicate the end of input and should not be processed. For each array in the input (except the termination line), output True
if it is a mountain array and False
otherwise.
inputFormat
The input is read from standard input (stdin). Each test case consists of multiple lines. Each line, except the last one, contains a space-separated list of integers representing an array. The input ends with a line that contains only -1
(which should not be processed).
Example:
2 1 1 2 3 4 5 0 3 2 1 0 1 2 2 1 -1
outputFormat
For every valid input line (array) read, output a single line to standard output (stdout) containing either True
or False
based on whether the given array qualifies as a mountain array.
Example corresponding to the input above:
False False True False## sample
2 1
1 2 3 4 5
0 3 2 1 0
1 2 2 1
-1
False
False
True
False
</p>