#C1871. Strictly Increasing Sequence
Strictly Increasing Sequence
Strictly Increasing Sequence
You are given an array of integers. Your task is to determine whether the array can be transformed into a strictly increasing sequence by removing at most one element.
A sequence \( a_1, a_2, \dots, a_n \) is strictly increasing if it satisfies \( a_1 < a_2 < \dots < a_n \). In other words, every element must be smaller than the next one.
If the given array is already strictly increasing, the answer is YES
. Otherwise, check if there exists an index such that removing the element at that index results in a strictly increasing array. If such an element exists, output YES
; otherwise, output NO
.
Note: You are allowed to remove at most one element.
inputFormat
The input is given via stdin and has the following format:
T n_1 a[1] a[2] ... a[n_1] n_2 a[1] a[2] ... a[n_2] ...</p>n_T a[1] a[2] ... a[n_T]
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 array. The next line contains n
space-separated integers.
outputFormat
For each test case, print a single line to stdout containing YES
if it is possible to obtain a strictly increasing sequence by removing at most one element, or NO
otherwise.
3
3
1 3 2
4
4 2 3 5
5
1 2 3 4 5
YES
YES
YES
</p>