#P2362. 围栏木桩
围栏木桩
Description
A farm has a non-circular fence consisting of posts arranged in order by their indices. We want to select some posts such that, when kept in their original index order, the selected posts' heights form a non-decreasing sequence. A non-decreasing sequence means every number in the sequence is not less than any number before it. Write a program to select posts so that the number of selected posts is maximized, and compute the total number of selection schemes that achieve posts.
Input Format
The first line contains a single integer , indicating that there are test cases.
Each test case is given on one line as followed by integers (where denotes the height of the -th post), all separated by spaces.
Output Format
For each test case, output and . Print one test case per line, with and separated by a space.
3
9 10 1 9 8 7 6 3 4 6
3 100 70 102
6 40 37 23 89 91 12
4 1
2 2
3 3
Hint
,,.
Translated by ChatGPT 5
京公网安备 11011102002149号