Dynamic Programming21 sections · 916 units
Open in Course

Gosha - Walkthrough

Two-dimensional application

Find the largest expected catches with at most AA Poke balls and BB Ultra balls. Two constraints=twoconstraints = two penalties. Outer binary search on λA\lambda_A. Inner: either binary search on λB\lambda_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))O(N \log^2(\text{range})) if nested binary search. Complexity grows with constraint dimensions.