#C7424. Minimum Operations for Strictly Increasing Sequence

    ID: 51294 Type: Default 1000ms 256MiB

Minimum Operations for Strictly Increasing Sequence

Minimum Operations for Strictly Increasing Sequence

You are given an array of integers. Your task is to determine the minimum number of operations required to make the array strictly increasing. In one operation, you can remove an element from the array. Equivalently, you can think of this as finding the longest strictly increasing subsequence (LIS) of the array and then removing all other elements. Formally, if the length of the array is \(n\) and the length of the longest strictly increasing subsequence is \(L\), then the answer is \(n - L\).

Note: A sequence \(a_1, a_2, \ldots, a_n\) is strictly increasing if \(a_1 < a_2 < \cdots < a_n\).

inputFormat

The input is read from stdin and has the following format:

T
n_1
a_{1,1} a_{1,2} ... a_{1,n_1}
... 
n_T
a_{T,1} a_{T,2} ... a_{T,n_T}

Where:

  • 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, followed by a line with \(n\) space-separated integers.

outputFormat

For each test case, print a single line containing a single integer: the minimum number of removal operations required to make the array strictly increasing.

## sample
3
3
1 2 3
4
3 1 2 1
5
5 5 5 5 5
0

2 4

</p>