Tap here to switch tabs
Problem
Submissions

Problem: Maximum Bags With Full Capacity of Rocks

med
30 min
Try to solve the Maximum Bags With Full Capacity of Rocks problem.

Statement

You are given two integer arrays capacity and rocks, each of length n, along with an integer additionalRocks.

For each bag i, capacity[i] represents its total rock capacity, and rocks[i] represents the quantity of rocks currently inside it. You have additionalRocks more rocks that you can distribute among any of the bags.

Return the maximum count of bags that can reach full capacity after placing the additional rocks.

Constraints:

  • n == capacity.length == rocks.length

  • 1≤1 \leq n ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq capacity[i] ≤109\leq 10^9

  • 0≤0 \leq rocks[i] ≤\leq capacity[i]

  • 1≤1 \leq additionalRocks ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Bags With Full Capacity of Rocks

med
30 min
Try to solve the Maximum Bags With Full Capacity of Rocks problem.

Statement

You are given two integer arrays capacity and rocks, each of length n, along with an integer additionalRocks.

For each bag i, capacity[i] represents its total rock capacity, and rocks[i] represents the quantity of rocks currently inside it. You have additionalRocks more rocks that you can distribute among any of the bags.

Return the maximum count of bags that can reach full capacity after placing the additional rocks.

Constraints:

  • n == capacity.length == rocks.length

  • 1≤1 \leq n ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq capacity[i] ≤109\leq 10^9

  • 0≤0 \leq rocks[i] ≤\leq capacity[i]

  • 1≤1 \leq additionalRocks ≤109\leq 10^9