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.
Note that limit can be as large as a billion, so walking through the numbers one by one will not do.blocked=[2, 5], limit=10, budget=20 → 4
Take the smallest allowed numbers: 1, 3, 4 and 6, for a sum of 14. The next one, 7, would bring it to 21.
blocked=[1], limit=1000000000, budget=1 → 0
1 is forbidden, and every other number is above the budget.
blocked=[3], limit=3, budget=1000000000000000 → 2
len(blocked) ≤ 10⁵blocked[i] ≤ limit ≤ 10⁹budget ≤ 10¹⁸blocked=[2, 5], limit=10, budget=20
4
Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.