#C6660. Non-Decreasing Flowers
Non-Decreasing Flowers
Non-Decreasing Flowers
You are given a sequence of ( n ) integers representing the heights of flowers arranged in a row. You are allowed to remove at most one flower from the sequence. Your task is to determine whether it is possible to obtain a non-decreasing sequence by removing at most one element. In other words, you need to check if there exists an index such that after its removal, the sequence ( a_1, a_2, \ldots, a_n ) satisfies ( a_i \leq a_{i+1} ) for all valid ( i ).
For example, for the sequence [1, 3, 2, 4, 5], by removing the flower with height 3 or 2, the remaining sequence becomes non-decreasing. Print "yes" if it is possible, otherwise print "no".
inputFormat
The first line contains an integer ( n ) (( 1 \leq n \leq 10^5 )) indicating the number of flowers. The second line contains ( n ) space-separated integers representing the heights of the flowers.
outputFormat
Output a single line with the word "yes" if the sequence can be made non-decreasing by removing at most one element, otherwise output "no".## sample
5
1 3 2 4 5
yes