Skip to content

Practice Maximum Number of Robots Within Budget

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2398
LeetCode Problem

Maximum Number of Robots Within Budget

Problem Statement

You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget. The total cost of running k chosen robots is equal to max(chargeTimes) + k * sum(runningCosts), where max(chargeTimes) is the largest charge cost among the k robots and sum(runningCosts) is the sum of running costs among the k robots. Return the maximum number of consecutive robots you can run such that the total cost does not exceed budget.

Source: Maximum Number of Robots Within Budget on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25
Output
3

# Example 2

Input
chargeTimes = [11,12,19], runningCosts = [10,8,7], budget = 19
Output
0

Constraints

chargeTimes.length == runningCosts.length == n
1 <= n <= 5 * 10^4
1 <= chargeTimes[i], runningCosts[i] <= 10^5
1 <= budget <= 10^15

Related LeetCode Problems

Practice more problems similar to Maximum Number of Robots Within Budget.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.