CF1334B.Middle Class

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Many years ago Berland was a small country where only nn people lived. Each person had some savings: the ii-th one had aia_i burles.

The government considered a person as wealthy if he had at least xx burles. To increase the number of wealthy people Berland decided to carry out several reforms. Each reform looked like that:

  • the government chooses some subset of people (maybe all of them);
  • the government takes all savings from the chosen people and redistributes the savings among the chosen people equally.

For example, consider the savings as list [5,1,2,1][5, 1, 2, 1]: if the government chose the 11-st and the 33-rd persons then it, at first, will take all 5+2=75 + 2 = 7 burles and after that will return 3.53.5 burles to the chosen people. As a result, the savings will become [3.5,1,3.5,1][3.5, 1, 3.5, 1].

A lot of data was lost from that time, so we don't know how many reforms were implemented and to whom. All we can do is ask you to calculate the maximum possible number of wealthy people after several (maybe zero) reforms.

很多年前,贝尔兰是一个只有 nn 个人居住的小国家。每个人都有一定的储蓄:第 ii 个人有 aia_i 布尔(burles)。

如果一个人至少拥有 xx 布尔,政府就认为他是富有的。为了增加富有人数,贝尔兰决定实施若干次改革。每次改革的形式如下:

  • 政府选择某个人的子集(可能包含所有人);
  • 政府从被选中的人那里收走全部储蓄,并将这些储蓄在被选中的人之间平均分配。

例如,考虑储蓄列表 [5,1,2,1][5, 1, 2, 1]:若政府选择了第 11 个人和第 33 个人,则首先收走全部 5+2=75 + 2 = 7 布尔,然后将这 77 布尔平均分给这两人,每人得到 3.53.5 布尔。结果储蓄变为 [3.5,1,3.5,1][3.5, 1, 3.5, 1]。

那个时代大量数据已遗失,因此我们不知道究竟实施了多少次改革、以及每次改革针对哪些人。我们唯一能做的,就是请你计算:经过若干次(可能为零次)改革后,富有人数的最大可能值。

输入格式

The first line contains single integer TT (1≤T≤10001 \le T \le 1000) — the number of test cases.

Next 2T2T lines contain the test cases — two lines per test case. The first line contains two integers nn and xx (1≤n≤1051 \le n \le 10^5, 1≤x≤1091 \le x \le 10^9) — the number of people and the minimum amount of money to be considered as wealthy.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the initial savings of each person.

It's guaranteed that the total sum of nn doesn't exceed 10510^5.

第一行包含一个整数 TT(1≤T≤10001 \le T \le 1000)—— 表示测试用例的数量。

接下来的 2T2T 行包含测试用例,每个测试用例占两行。第一行包含两个整数 nn 和 xx(1≤n≤1051 \le n \le 10^5,1≤x≤1091 \le x \le 10^9)—— 分别表示人数以及被认定为“富裕”所需的最低金额。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 表示每个人的初始存款。

保证所有测试用例中 nn 的总和不超过 10510^5。

输出格式

Print TT integers — one per test case. For each test case print the maximum possible number of wealthy people after several (maybe zero) reforms.

输出 TT 个整数——每个测试用例对应一个整数。对于每个测试用例,输出经过若干次(可能为零次)改革后,富有人数的最大可能值。

输入输出样例

  • 输入#1

    4
    4 3
    5 1 2 1
    4 10
    11 9 11 9
    2 5
    4 3
    3 7
    9 4 9

    输出#1

    2
    4
    0
    3

说明/提示

The first test case is described in the statement.

In the second test case, the government, for example, could carry out two reforms: [11‾,9‾,11,9]→[10,10,11‾,9‾]→[10,10,10,10][\underline{11}, \underline{9}, 11, 9] \rightarrow [10, 10, \underline{11}, \underline{9}] \rightarrow [10, 10, 10, 10].

In the third test case, the government couldn't make even one person wealthy.

In the fourth test case, the government could choose all people to carry out a reform: [9‾,4‾,9‾]→[713,713,713][\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}].

第一个测试用例已在题目描述中给出。

在第二个测试用例中,政府例如可以实施两次改革:[11‾,9‾,11,9]→[10,10,11‾,9‾]→[10,10,10,10][\underline{11}, \underline{9}, 11, 9] \rightarrow [10, 10, \underline{11}, \underline{9}] \rightarrow [10, 10, 10, 10]。

在第三个测试用例中,政府甚至无法使一个人变得富有。

在第四个测试用例中,政府可以选择所有人来实施一次改革:[9‾,4‾,9‾]→[713,713,713][\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}]。

输入解题思路,AI测评打分。不知道怎么写?

首页