#K45042. Minimum Removals for Sum Threshold
Minimum Removals for Sum Threshold
Minimum Removals for Sum Threshold
You are given an array of integers and a target sum (T). Your task is to remove the minimum number of elements from the array such that the sum of the remaining elements is less than or equal to (T).
For example, if the array is [1, 2, 3, 4, 5] and (T = 10), by removing 5 the remaining sum becomes 10 which meets the condition. Your solution must compute the minimum number of removals required.
inputFormat
The first line contains two integers (n) and (T), where (n) is the number of elements in the array and (T) is the target sum. The second line contains (n) space-separated integers representing the elements of the array.
outputFormat
Output a single integer: the minimum number of elements that need to be removed so that the sum of the remaining elements is less than or equal to (T).## sample
5 10
1 2 3 4 5
1