A13456 | Middle Class
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Many years ago Berland was a small country where only $n$ people lived. Each person had some savings: the $i$ -th one had $a_i$ burles.
The government considered a person as wealthy if he had at least $x$ 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]$ : if the government chose the $1$ -st and the $3$ -rd persons then it, at first, will take all $5 + 2 = 7$ burles and after that will return $3.5$ burles to the chosen people. As a result, the savings will become $[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.
The government considered a person as wealthy if he had at least $x$ 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]$ : if the government chose the $1$ -st and the $3$ -rd persons then it, at first, will take all $5 + 2 = 7$ burles and after that will return $3.5$ burles to the chosen people. As a result, the savings will become $[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.
输入格式
The first line contains single integer $T$ ( $1 \le T \le 1000$ ) — the number of test cases.
Next $2T$ lines contain the test cases — two lines per test case. The first line contains two integers $n$ and $x$ ( $1 \le n \le 10^5$ , $1 \le x \le 10^9$ ) — the number of people and the minimum amount of money to be considered as wealthy.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 10^9$ ) — the initial savings of each person.
It's guaranteed that the total sum of $n$ doesn't exceed $10^5$ .
Next $2T$ lines contain the test cases — two lines per test case. The first line contains two integers $n$ and $x$ ( $1 \le n \le 10^5$ , $1 \le x \le 10^9$ ) — the number of people and the minimum amount of money to be considered as wealthy.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 10^9$ ) — the initial savings of each person.
It's guaranteed that the total sum of $n$ doesn't exceed $10^5$ .
输出格式
Print $T$ integers — one per test case. For each test case print the maximum possible number of wealthy people after several (maybe zero) reforms.
输入输出样例
输入 #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: $[\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: $[\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}]$ .
In the second test case, the government, for example, could carry out two reforms: $[\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: $[\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted