blocked and two integers limit and budget. Choose a set of distinct integers such that:
- every number lies between 1 and limit, inclusive;
- none of them appears in blocked;
- their sum does not exceed budget.
Return the largest count of numbers you can choose under these rules.blocked=[2, 3], limit=8, budget=12 → 3
Take 1, 4 and 5 for a sum of 10. Adding the next allowed number, 6, would push the sum to 16.
blocked=[9], limit=4, budget=100 → 4
9 is outside the range anyway, and 1 through 4 add up to 10, so all four fit.
blocked=[1, 2], limit=5, budget=2 → 0
The smallest allowed number is 3, which already exceeds the budget.
len(blocked) ≤ 10⁵blocked[i] ≤ 10⁵limit ≤ 10⁵budget ≤ 10⁹blocked=[2, 3], limit=8, budget=12
3
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.