Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Maximum Total from Optimal Activation Order

XPChallenge Points: 20
levelLevel: Medium

You are given two integer arrays energy and threshold, each of length n.
Initially, all reactors are inactive. You can activate them in any order, but under specific conditions:
• To activate a reactor at index i, the number of currently active reactors must be strictly less than threshold[i].
• When you activate reactor i, it contributes energy[i] to your total energy output.
• After each activation, if the number of currently active reactors becomes x, then all reactors j where threshold[j] <= x become permanently inactive, even if they are currently active.
Your task is to determine the maximum total energy that can be achieved through an optimal activation sequence.

Example 1:

Input: energy = [6, 2, 9] threshold = [3, 1, 2]

Output: 17

Example 2:

Input: energy = [5, 10, 3] threshold = [1, 1, 1]

Output: 18

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result