CF1610E.AmShZ and G.O.A.T.
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call an array of k integers c1,c2,…,ck terrible, if the following condition holds:
-
Let AVG be the kc1+c2+…+ck (the average of all the elements of the array, it doesn't have to be integer). Then the number of elements of the array which are bigger than AVG should be strictly larger than the number of elements of the array which are smaller than AVG . Note that elements equal to AVG don't count.
For example c={1,4,4,5,6} is terrible because AVG=4.0 and 5 -th and 4 -th elements are greater than AVG and 1 -st element is smaller than AVG .
Let's call an array of m integers b1,b2,…,bm bad, if at least one of its non-empty subsequences is terrible, and good otherwise.
You are given an array of n integers a1,a2,…,an . Find the minimum number of elements that you have to delete from it to obtain a good array.
An array is a subsequence of another array if it can be obtained from it by deletion of several (possibly, zero or all) elements.
输入格式
The first line contains an integer t ( 1≤t≤104 ) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer n ( 2≤n≤2⋅105 ) — the size of a .
The second line of each testcase contains n integers a1,a2,…,an ( 1≤ai≤109 ) — elements of array a .
In each testcase for any 1≤i<n it is guaranteed that ai≤ai+1 .
It is guaranteed that the sum of n over all testcases doesn't exceed 2⋅105 .
输出格式
For each testcase, print the minimum number of elements that you have to delete from it to obtain a good array.
输入输出样例
输入#1
4 3 1 2 3 5 1 4 4 5 6 6 7 8 197860736 212611869 360417095 837913434 8 6 10 56026534 405137099 550504063 784959015 802926648 967281024
输出#1
0 1 2 3
说明/提示
In the first sample, the array a is already good.
In the second sample, it's enough to delete 1 , obtaining array [4,4,5,6] , which is good.