loads[i] and lifters with strength lifters[j]. A lifter can carry a load if their strength is at least its weight, and each lifter carries at most one load.
There are also drinks energy drinks. A drink raises its drinker's strength by boost, and each lifter may have at most one. You decide who gets them.
Return the largest number of loads that can be carried.loads=[6, 2, 9], lifters=[5, 9, 1], drinks=1, boost=2 → 2
For example, the lifter with strength 9 carries the 9, and the lifter with strength 5 drinks and carries the 6. All three is impossible: there is one drink, but both the lifter with 5 (for the 6) and the lifter with 1 (for the 2) would need it.
loads=[4, 4], lifters=[1, 2, 3], drinks=3, boost=2 → 2
After a drink the lifters have strength 3, 4 and 5, so two of them can handle a load of 4.
loads=[10], lifters=[3, 4], drinks=2, boost=5 → 0
Even after a drink the strongest lifter manages only 9, less than 10.
loads=[6, 2, 9], lifters=[5, 9, 1], drinks=1, boost=2
2
Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.