#K37907. Minimum Book Pile Stacking

    ID: 26080 Type: Default 1000ms 256MiB

Minimum Book Pile Stacking

Minimum Book Pile Stacking

You are given a sequence of books where each book has an integer thickness. Your task is to arrange the books into piles following the stacking rule: a book can be placed on top of a pile only if the thickness of the book on the top of the pile is \( \geq \) the thickness of the new book. The aim is to minimize the number of piles required.

Formally, assume you have a list of book thicknesses \(a_1, a_2, \dots, a_n\). You want to partition this sequence into a minimum number of piles \(P_1, P_2, \dots, P_k\) such that for each pile \(P_i\) with books arranged in order of placement \(b_{i,1}, b_{i,2}, \dots, b_{i,m}\), the following condition holds:

[ b_{i,1} \geq b_{i,2} \geq \cdots \geq b_{i,m} ]

Determine the minimum number of piles needed to stack all the books.

inputFormat

The input is given via standard input (stdin) and has the following format:

  1. The first line contains an integer \(T\) indicating the number of test cases.
  2. For each test case:
    • The first line contains an integer \(n\), the number of books.
    • The second line contains \(n\) space-separated integers representing the thicknesses of the books.

outputFormat

For each test case, print on a separate line a single integer: the minimum number of piles required to stack the books according to the given rule. Output the results via standard output (stdout).

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

2

</p>