#K6866. Sequence Selection and Mean Comparison
Sequence Selection and Mean Comparison
Sequence Selection and Mean Comparison
You are given a multiset of n integers S. Your task is to determine if it is possible to select exactly k integers from S such that the arithmetic mean of the selected sequence is strictly greater than a given integer a.
The arithmetic mean of a sequence \(s_1, s_2, \ldots, s_k\) is defined as:
[ \text{mean} = \frac{s_1+s_2+\cdots+s_k}{k} ]
You need to check whether there exists a selection of k integers from S for which:
[ \frac{s_1+s_2+\cdots+s_k}{k} > a ]
If such a selection exists, output YES
; otherwise, output NO
. It is guaranteed that you must use exactly k elements from S.
inputFormat
The input is given via standard input and consists of multiple test cases. The format is as follows:
- The first line contains an integer
T
(T ≥ 1), representing the number of test cases. - For each test case:
- The first line contains three integers
n
,k
, anda
wheren
is the number of elements in the multiset,k
is the number of elements you need to select, anda
is the threshold value. - The second line contains
n
space-separated integers, representing the elements of S.
- The first line contains three integers
Note: It is guaranteed that 1 ≤ k ≤ n
.
outputFormat
For each test case, output a single line containing YES
if it is possible to select a sequence of k numbers such that their arithmetic mean is greater than a
. Otherwise, output NO
.
The answers for different test cases should be printed in the order of the input test cases, each on a new line.
## sample1
5 3 5
1 2 3 7 9
YES
</p>