#K63657. Maximizing Employee Resource Allocation
Maximizing Employee Resource Allocation
Maximizing Employee Resource Allocation
Given n employees and a total of W computing units, each employee i requires ai units. The goal is to maximize the number of employees whose requests can be fully satisfied without exceeding the total available computing units W. Formally, you need to choose a subset S of employees such that
$$ \sum_{i \in S} a_i \leq W $$
and S is as large as possible. This problem can be effectively solved using a greedy strategy by sorting the requirements in non-decreasing order and then satisfying the smallest requests first.
inputFormat
The input is read from standard input (stdin).
The first line contains two space-separated integers, n and W, where n is the number of employees and W is the total available computing units. The second line contains n space-separated integers, representing the computing unit requirements a1, a2, ..., an for each employee.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of employees whose computing requirements can be fully satisfied without exceeding W.## sample
4 10
2 3 5 7
3