CF1759E.The Humanoid
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n astronauts working on some space station. An astronaut with the number i ( 1≤i≤n ) has power ai .
An evil humanoid has made his way to this space station. The power of this humanoid is equal to h . Also, the humanoid took with him two green serums and one blue serum.
In one second , a humanoid can do any of three actions:
- to absorb an astronaut with power strictly less humanoid power;
- to use green serum, if there is still one left;
- to use blue serum, if there is still one left.
When an astronaut with power ai is absorbed, this astronaut disappears, and power of the humanoid increases by ⌊2ai⌋ , that is, an integer part of 2ai . For example, if a humanoid absorbs an astronaut with power 4 , its power increases by 2 , and if a humanoid absorbs an astronaut with power 7 , its power increases by 3 .
After using the green serum, this serum disappears, and the power of the humanoid doubles, so it increases by 2 times.
After using the blue serum, this serum disappears, and the power of the humanoid triples, so it increases by 3 times.
The humanoid is wondering what the maximum number of astronauts he will be able to absorb if he acts optimally.
输入格式
The first line of each test contains an integer t ( 1≤t≤104 ) — number of test cases.
The first line of each test case contains integers n ( 1≤n≤2⋅105 ) — number of astronauts and h ( 1≤h≤106 ) — the initial power of the humanoid.
The second line of each test case contains n integers ai ( 1≤ai≤108 ) — powers of astronauts.
It is guaranteed that the sum of n for all test cases does not exceed 2⋅105 .
输出格式
For each test case, in a separate line, print the maximum number of astronauts that a humanoid can absorb.
输入输出样例
输入#1
8 4 1 2 1 8 9 3 3 6 2 60 4 5 5 1 100 5 3 2 38 6 3 1 1 12 4 6 12 12 36 100 4 1 2 1 1 15 3 5 15 1 13
输出#1
4 3 3 3 0 4 4 3
说明/提示
In the first case, you can proceed as follows:
- use green serum. h=1⋅2=2
- absorb the cosmonaut 2 . h=2+⌊21⌋=2
- use green serum. h=2⋅2=4
- absorb the spaceman 1 . h=4+⌊22⌋=5
- use blue serum. h=5⋅3=15
- absorb the spaceman 3 . h=15+⌊28⌋=19
- absorb the cosmonaut 4 . h=19+⌊29⌋=23