#C6680. Make the Sequence Strictly Increasing

    ID: 50467 Type: Default 1000ms 256MiB

Make the Sequence Strictly Increasing

Make the Sequence Strictly Increasing

You are given a sequence of integers. Your task is to determine whether it is possible to remove at most one element from the sequence such that the remaining sequence is strictly increasing. A strictly increasing sequence is defined as one in which every element is less than its subsequent element, i.e., (a_0 < a_1 < \cdots < a_{n-1}).

For example:

  • For the sequence [1, 2, 10, 5, 7], removing 10 results in [1, 2, 5, 7], which is strictly increasing. Hence, the output is True.
  • For the sequence [2, 3, 1, 2], no single removal can achieve a strictly increasing order. Thus, the output is False.

Note: If the sequence is already strictly increasing, then no removal is needed and the answer should be True.

inputFormat

The first line contains an integer (n) representing the number of elements in the sequence.\nThe second line contains (n) space-separated integers forming the sequence.

outputFormat

Output a single line with True if it is possible to remove at most one element to obtain a strictly increasing sequence; otherwise, output False.## sample

5
1 2 10 5 7
True