#K81012. Maximizing Task Completion

    ID: 35659 Type: Default 1000ms 256MiB

Maximizing Task Completion

Maximizing Task Completion

You are given N tasks and a total available time T. Each task requires a certain amount of time to complete. Your goal is to determine the maximum number of tasks that can be completed without exceeding the total time T. The tasks can be performed in any order; thus, it is optimal to complete tasks with shorter duration first.

Mathematically, if the sorted task times are \( t_1 \le t_2 \le \dots \le t_N \), then you need to find the largest integer \( k \) such that \[ \sum_{i=1}^{k} t_i \le T. \]

Input: The first line contains two integers, N and T. The second line contains N space-separated integers representing the time required for each task.

Output: A single integer representing the maximum number of tasks that can be completed within the time T.

inputFormat

The input is given via standard input and consists of two lines. The first line contains two integers N (the number of tasks) and T (the total available time). The second line contains N space-separated integers where each integer represents the time required to complete a task.

outputFormat

The output is a single integer printed to standard output, which is the maximum number of tasks that can be completed within the given total time T.

## sample
5 10
2 1 3 4 2
4

</p>