#C3685. Maximizing Funded Projects

    ID: 47139 Type: Default 1000ms 256MiB

Maximizing Funded Projects

Maximizing Funded Projects

You are given N projects, each with a required budget given in an array. The company has a total available budget of B. Your task is to determine the maximum number of projects that can be fully funded without exceeding the available budget.

Formally, let \(N\) be the number of projects and \(A = [a_1, a_2, \dots, a_N]\) be their respective budget requirements. You need to choose a subset of projects such that the sum of their budgets is at most \(B\) and the number of projects selected is maximized. A greedy strategy by sorting the budgets in ascending order yields the optimal solution.

inputFormat

The first line contains two integers N and B separated by a space, where N is the number of projects and B is the total available budget.

The second line contains N integers representing the budget required for each project. The integers are separated by spaces.

outputFormat

Output a single integer representing the maximum number of projects that can be fully funded without exceeding the total budget.

## sample
5 50
10 20 30 40 50
2

</p>