LIS 翻转
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
题面翻译
设一个长为 的整数序列 是 ,那么 表示 , 表示 的最长严格上升子序列的长度。
现在给定 数组,请你将 数组重新排列,使得重排后的 最大。
输入 组数据,每组数据先输入 ,然后输入 个整数,所有 之和不超过 。
输出 行,每行一组数据的答案,按输入顺序输出。
题目描述
You are given an array of positive integers.
Let denote the length of longest strictly increasing subsequence of . For example,
- = .
- = .
- = .
We define array as the array obtained after reversing the array i.e. .
The beauty of array is defined as .
Your task is to determine the maximum possible beauty of the array if you can rearrange the array arbitrarily.
输入格式
The input consists of multiple test cases. The first line contains a single integer — the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer — the length of array .
The second line of each test case contains integers — the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, output a single integer — the maximum possible beauty of after rearranging its elements arbitrarily.
样例 #1
样例输入 #1
3
3
6 6 6
6
2 5 4 5 2 4
4
1 3 2 2
样例输出 #1
1
3
2
提示
In the first test case, = and = . = . Hence the beauty is .
In the second test case, can be rearranged to . Then = . . Hence the beauty is and it can be shown that this is the maximum possible beauty.
In the third test case, can be rearranged to . Then = . , . Hence the beauty is and it can be shown that is the maximum possible beauty.
1.16测试题
- Status
- Done
- Rule
- IOI
- Problem
- 3
- Start at
- 2024-1-16 15:00
- End at
- 2024-1-16 18:00
- Duration
- 3 hour(s)
- Host
- Partic.
- 0