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