Find the largest expected catches with at most Poke balls and Ultra balls. Two penalties. Outer binary search on . Inner: either binary search on or solve directly. With both penalties, each Pokemon's optimal allocation is independent.
But we need the count for both ball types. Total: if nested binary search. Complexity grows with constraint dimensions.