You are given three integers `R1`, `R2`, and `R3`, representing the maximum available units of three different resources. You are also given a 2D integer array `demands` of size `n` where `demands[i] = [r1_i, r2_i, r3_i]` represents the required units of the three resources to satisfy the `i`-th demand. Return the maximum number of demands you can satisfy such that the total resources used do not exceed `R1`, `R2`, and `R3` respectively.
Explanation: We can satisfy the first two demands [2, 1, 1] and [1, 2, 1], requiring a total of [3, 3, 2] resources, which does not exceed [5, 4, 3].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak