Pro.ID22796 TitleAntimonotonicity Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22796 AC22 Submit59 Ratio37.29% 时间&空间限制描述I have a sequence Fred of length n comprised of integers between 1 and n inclusive. The elements of Fred are pairwise distinct. I want to find a subsequence Mary of Fred that is as long as possible and has the property that: Mary0 > Mary1 < Mary2 > Mary3 < ... 输入The first line of input will contain a single integer T expressed in decimal with no leading zeroes. T will be at most 50. T test cases will follow. Each test case contains a single line. A line describing a test case is formatted as follows: n Fred0 Fred1 Fred2 ... Fredn-1 where n and each element of Fred is an integer expressed in decimal with no leading zeroes. No line will have leading or trailing whitespace, and two adjacent integers on the same line will be separated by a single space. n willbe at most 30000. 输出Description I have a sequence Fred of length n comprised of integers between 1 and n inclusive. The elements of Fred are pairwise distinct. I want to find a subsequence Mary of Fred that is as long as possible and has the property that: Mary0 > Mary1 < Mary2 > Mary3 < ... Input The first line of input will contain a single integer T expressed in decimal with no leading zeroes. T will be at most 50. T test cases will follow. Each test case contains a single line. A line describing a test case is formatted as follows: n Fred0 Fred1 Fred2 ... Fredn-1 where n and each element of Fred is an integer expressed in decimal with no leading zeroes. No line will have leading or trailing whitespace, and two adjacent integers on the same line will be separated by a single space. n willbe at most 30000. Output For each test case, output a single integer followed by a new line --- the length of the longest subsequence Mary of Fred with the desired properties. Sample Input 4 Sample Output 1 Source 样例输入4 样例输出1 作者 |