#K69122. Max Events per Day

    ID: 33017 Type: Default 1000ms 256MiB

Max Events per Day

Max Events per Day

You are given several test cases. In each test case, you are provided with an integer n representing the number of events and an integer H representing the total number of hours available in a community center. In addition, you are given n space-separated integers indicating the duration (in hours) of each event.

Your task is to determine the maximum number of events that can be held in a single day without exceeding the available time H. To do this, sort the event durations in non-decreasing order and select events one by one until the total duration would exceed H. Formally, given sorted durations \(d_1 \le d_2 \le \dots \le d_n\), find the largest integer k such that \(\sum_{i=1}^{k} d_i \le H\).

This greedy approach ensures that you schedule as many events as possible.

inputFormat

The input is given via stdin and has the following format:

  1. The first line contains an integer T representing the number of test cases.
  2. For each test case:
    1. The first line contains two space-separated integers, n (the number of events) and H (the total available hours).
    2. The second line contains n space-separated integers representing the duration of each event.

outputFormat

For each test case, output a single integer on a new line representing the maximum number of events that can be scheduled without exceeding the available hours.

## sample
3
5 10
2 3 1 5 8
4 5
4 3 2 1
6 8
1 2 3 4 5 6
3

2 3

</p>