#P9867. D. Medians Strike Back
D. Medians Strike Back
D. Medians Strike Back
Problem Description
Define the median of a sequence of length as: If is odd, the median is the number ranked if we sort the sequence in ascending order. If is even, the median is the number that has more occurences between the numbers ranked and if we sort the sequence in ascending order. If they appeared for the same number of times the smaller one is the median. Define the shikness of a sequence as the number of occurences of the median of . Define the nitness of a sequence as the maximum shikness over all continuous subsequences of . You want to find a sequence of length , satisfying for every , with the minimum nitness. Calculate the nitness of such sequence.
Input
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 one integer ().
Output
For each test case, print a single integer - the nitness of such sequence.
Sample Input
6
1
2
3
4
5
6
Sample Output
1
1
1
2
2
2
Source
2023“钉耙编程”中国大学生算法设计超级联赛(7)