#C11565. Make Array Increasing by Removing One Element
Make Array Increasing by Removing One Element
Make Array Increasing by Removing One Element
You are given an array of integers. Your task is to determine whether the array can be made strictly increasing by removing exactly one element from it.
An array A is strictly increasing if for every \( 1 \leq i < n \), \( A[i] < A[i+1] \). You are allowed to remove one element (and only one element) from the array. After removal, if the remaining array is strictly increasing, output Yes
; otherwise, output No
.
Note: If the array is already strictly increasing, the answer is still Yes
because you can remove any one element and the property may hold.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a single integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Output a single line to standard output (stdout) containing either Yes
if the array can be made strictly increasing by removing exactly one element, or No
otherwise.
5
1 2 10 5 7
Yes