#C6752. Beautiful Mountain Sequence
Beautiful Mountain Sequence
Beautiful Mountain Sequence
You are given a sequence of mountain heights. Your task is to determine whether the sequence is beautiful.
A sequence of n integers A = [A1, A2, \dots, An] is considered beautiful if and only if there exists an index k (with \(1 < k < n\)) such that:
\(A_1 < A_2 < \cdots A_{k+1} > \cdots > A_n\).
Note that:
- The sequence must strictly increase and then strictly decrease.
- The peak cannot be the first or the last element.
- If the sequence does not meet these conditions or its length is less than 3, it is not beautiful.
inputFormat
The input is read from standard input (stdin) and has the following format:
T n1 A1 A2 ... An1 n2 A1 A2 ... An2 ... nT A1 A2 ... AnT
Here, T is the number of test cases. For each test case, the first line contains an integer n representing the number of elements in the sequence, followed by a line with n space-separated integers representing the heights.
outputFormat
For each test case, output a single line to standard output (stdout) containing either Yes
if the sequence is beautiful, or No
otherwise.
The outputs for each test case should appear in the same order as the input test cases.
## sample4
5
1 2 3 1 0
6
1 2 4 3 2 1
3
1 3 2
5
1 3 3 2 1
Yes
Yes
Yes
No
</p>