#K6866. Sequence Selection and Mean Comparison

    ID: 32914 Type: Default 1000ms 256MiB

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:

  1. The first line contains an integer T (T ≥ 1), representing the number of test cases.
  2. For each test case:
    1. The first line contains three integers n, k, and a where n is the number of elements in the multiset, k is the number of elements you need to select, and a is the threshold value.
    2. The second line contains n space-separated integers, representing the elements of S.

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.

## sample
1
5 3 5
1 2 3 7 9
YES

</p>