Tap here to switch tabs
Problem
Submissions

Problem: Maximum Capacity Within Budget

Maximum Capacity Within Budget gives machine costs and capacities. Choose at most two distinct machines with combined cost strictly below the budget, then return the greatest capacity total, or zero if none qualify.

Statement

You are given two integer arrays costs and capacity, both of length n, and an integer budget.

You may choose at most 22 distinct machines such that the sum of their costs is strictly less than budget.

Return the maximum total capacity that can be obtained. If no machines can be selected, return 00.

Constraints:

  • 1≤n=1 \leq n = costs.length == capacity.length ≤105\leq 10^5

  • 1≤1 \leq costs[i], capacity[i] ≤105\leq 10^5

  • 1≤1 \leq budget ≤2×105\leq 2 \times 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Capacity Within Budget

Maximum Capacity Within Budget gives machine costs and capacities. Choose at most two distinct machines with combined cost strictly below the budget, then return the greatest capacity total, or zero if none qualify.

Statement

You are given two integer arrays costs and capacity, both of length n, and an integer budget.

You may choose at most 22 distinct machines such that the sum of their costs is strictly less than budget.

Return the maximum total capacity that can be obtained. If no machines can be selected, return 00.

Constraints:

  • 1≤n=1 \leq n = costs.length == capacity.length ≤105\leq 10^5

  • 1≤1 \leq costs[i], capacity[i] ≤105\leq 10^5

  • 1≤1 \leq budget ≤2×105\leq 2 \times 10^5