3645. Maximum Total from Optimal Activation Order
You are given two integer arrays
valueandlimit, both of lengthn.Initially, all elements are inactive. You may activate them in any order.
- To activate an inactive element at index
i, the number of currently active elements must be strictly less thanlimit[i].- When you activate the element at index
i, it addsvalue[i]to the total activation value (i.e., the sum ofvalue[i]for all elements that have undergone activation operations).- After each activation, if the number of currently active elements becomes
x, then all elementsjwithlimit[j] <= xbecome permanently inactive, even if they are already active.Return the maximum total you can obtain by choosing the activation order optimally.
1 | class Solution { |