Beautiful Sequence
시간 제한3초메모리 제한1024 MB
수열을 재배열해 양쪽 이웃보다 작지 않은 원소의 수를 최대로 만든다.
문제
There is a sequence consisting of integers. We want to rearrange the integers to make the most beautiful sequence possible. A sequence is more beautiful when there are more members which are not less than their neighbors. The beauty of a sequence is the number of such members.
Write a program that will rearrange a given sequence to make it the most beautiful possible.
For example, if and the sequence is , the beauty of the given sequence is . However, if we rearrange the sequence to become , then the beauty of the rearranged sequence is , which is the maximum possible.
입력
The first line contains an integer , the number of test cases (). The test cases follow.
The first line of each test case contains an integer , the number of elements ().
The next line contains the elements of the sequence. Each element is an integer between and , inclusive.
The sum of over all test cases does not exceed .
출력
For each test case, print one line containing an integer: the highest beauty possible after rearrangement.