CF1783C.Yet Another Tournament

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are participating in Yet Another Tournament. There are n+1n + 1 participants: you and nn other opponents, numbered from 11 to nn .

Each two participants will play against each other exactly once. If the opponent ii plays against the opponent jj , he wins if and only if i>ji > j .

When the opponent ii plays against you, everything becomes a little bit complicated. In order to get a win against opponent ii , you need to prepare for the match for at least aia_i minutes — otherwise, you lose to that opponent.

You have mm minutes in total to prepare for matches, but you can prepare for only one match at one moment. In other words, if you want to win against opponents p1,p2,,pkp_1, p_2, \dots, p_k , you need to spend ap1+ap2++apka_{p_1} + a_{p_2} + \dots + a_{p_k} minutes for preparation — and if this number is greater than mm , you cannot achieve a win against all of these opponents at the same time.

The final place of each contestant is equal to the number of contestants with strictly more wins ++ 11 . For example, if 33 contestants have 55 wins each, 11 contestant has 33 wins and 22 contestants have 11 win each, then the first 33 participants will get the 11 -st place, the fourth one gets the 44 -th place and two last ones get the 55 -th place.

Calculate the minimum possible place (lower is better) you can achieve if you can't prepare for the matches more than mm minutes in total.

输入格式

The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

The first line of each test case contains two integers nn and mm ( 1n51051 \le n \le 5 \cdot 10^5 ; 0mi=1nai0 \le m \le \sum\limits_{i=1}^{n}{a_i} ) — the number of your opponents and the total time you have for preparation.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 0ai10000 \le a_i \le 1000 ), where aia_i is the time you need to prepare in order to win against the ii -th opponent.

It's guaranteed that the total sum of nn over all test cases doesn't exceed 51055 \cdot 10^5 .

输出格式

For each test case, print the minimum possible place you can take if you can prepare for the matches no more than mm minutes in total.

输入输出样例

  • 输入#1

    5
    4 401
    100 100 200 1
    3 2
    1 2 3
    5 0
    1 1 1 1 1
    4 0
    0 1 1 1
    4 4
    1 2 2 1

    输出#1

    1
    2
    6
    4
    1

说明/提示

In the first test case, you can prepare to all opponents, so you'll win 44 games and get the 11 -st place, since all your opponents win no more than 33 games.

In the second test case, you can prepare against the second opponent and win. As a result, you'll have 11 win, opponent 1111 win, opponent 2211 win, opponent 3333 wins. So, opponent 33 will take the 11 -st place, and all other participants, including you, get the 22 -nd place.

In the third test case, you have no time to prepare at all, so you'll lose all games. Since each opponent has at least 11 win, you'll take the last place (place 66 ).

In the fourth test case, you have no time to prepare, but you can still win against the first opponent. As a result, opponent 11 has no wins, you have 11 win and all others have at least 22 wins. So your place is 44 .

首页