| Bitshift2026-IITM,ProgClub |
|---|
| Finished |
ScepticallySam owns a speed packing service that uses robots to process packages.
Each robot is assigned a pair of indices $$$i \le j$$$ and performs the following operations on a line of packages:
A robot cannot move packages outside its assigned subarray.
Each line of packages is represented as an array of integers. For each line, ScepticallySam assigns robots to several non-overlapping subarrays, and all robots operate simultaneously.
After all robots finish, the entire line must be stamped and sorted in ascending order.
Given $$$t$$$ lines of packages, determine the maximum number of robots that can be assigned to each line while satisfying the above conditions.
Note: No robots were harmed in the making of this question.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) which represents the number of lines of packages.
The first line of the $$$i^{th}$$$ testcase contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$), the number of packages in the line.
The second line of the $$$i^{th}$$$ testcase contains $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ ($$$1 \le a_i \le 10^9$$$) representing the weight of each package in the line.
It is guaranteed that the sum of $$$n$$$ (The total number of packages) over all the testcases does not exceed $$$2 \cdot 10^5$$$.
For each line of packages, output one integer, which is the maximum number of robots required to completely stamp and sort all the packages in the array.
341 2 3 444 3 2 151 2 3 5 4
414
In the first testcase, we can allocate 1 robot to each box since it's already sorted. Hence, 4 robots can be used, which is the maximum number of robots that can be used.
In the second testcase, we must allocate 1 robot to the entire sequence. It is not possible to achieve the goal in any other way.
In the third testcase, we can allocate 1 robot to each of the first three boxes and 1 robot to the last two boxes. So 4 robots in total.
| Name |
|---|


