#C10580. Maximum Task Scheduling

    ID: 39801 Type: Default 1000ms 256MiB

Maximum Task Scheduling

Maximum Task Scheduling

You are given a list of tasks where each task requires a certain amount of time to complete. Additionally, you are provided with the total available time for the day, denoted by \(T\). Your goal is to determine the maximum number of tasks that can be completed without exceeding the total available time.

To solve this problem, you should sort the tasks in ascending order by their required time. Then, iterate through the sorted list and keep a cumulative total of the time taken. Count each task until adding the next task would exceed \(T\). The result is the maximum number of tasks that can be performed within the given time constraint.

inputFormat

The input is read from standard input and is formatted as follows:

  • The first line contains two space-separated integers \(n\) and \(T\), where \(n\) is the number of tasks and \(T\) is the total available time.
  • The second line contains \(n\) space-separated integers, each representing the time required for a task.

outputFormat

Output a single integer representing the maximum number of tasks that can be completed without exceeding the available time.

## sample
5 6
2 3 1 4 2
3