#K81432. Maximum Attractions
Maximum Attractions
Maximum Attractions
You are given a total available time \(T\) (in minutes) and a list of \(N\) attractions, each requiring a certain amount of time to visit. The goal is to determine the maximum number of attractions that can be visited without exceeding the total available time \(T\). You may visit the attractions in any order, but note that the optimum strategy is to select attractions with the shortest required time first. This ensures that you maximize the count of attractions visited.
Input Format: The input consists of two lines. The first line contains two space-separated integers \(T\) and \(N\), where \(T\) is the total available time and \(N\) is the number of attractions. The second line contains \(N\) space-separated integers, where each integer represents the time required for an attraction.
Example:
Input: 120 5 30 60 15 45 50</p>Output: 3
inputFormat
The first line of input contains two integers \(T\) and \(N\) (total available time and number of attractions, respectively). The second line contains \(N\) space-separated integers representing the time needed for each attraction.
outputFormat
Output a single integer representing the maximum number of attractions that can be visited without exceeding the total available time \(T\).
## sample120 5
30 60 15 45 50
3