Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Sum with Threshold Constraints

Try to solve the Maximum Total Sum with Threshold Constraints problem.

Statement

You are given two integer arrays nums and threshold, both of length n.

Starting at step = 11 with an initial sum of 00, you perform the following operation at each step:

  • Choose any unvisited index i such that threshold[i] \leq step.

  • Add nums[i] to the total sum and mark index i as visited.

  • Advance to step + 11.

If at any step no unvisited index i satisfies threshold[i] \leq step, the process terminates immediately. The process also terminates if all nn indices have been visited.

Return the maximum total sum that can be achieved.

Constraints:

  • $n ==$ nums.length ==== threshold.length

  • 1≤n≤1051 \leq n \leq 10^5

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

  • 1≤1 \leq threshold[i] ≤n\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Sum with Threshold Constraints

Try to solve the Maximum Total Sum with Threshold Constraints problem.

Statement

You are given two integer arrays nums and threshold, both of length n.

Starting at step = 11 with an initial sum of 00, you perform the following operation at each step:

  • Choose any unvisited index i such that threshold[i] \leq step.

  • Add nums[i] to the total sum and mark index i as visited.

  • Advance to step + 11.

If at any step no unvisited index i satisfies threshold[i] \leq step, the process terminates immediately. The process also terminates if all nn indices have been visited.

Return the maximum total sum that can be achieved.

Constraints:

  • $n ==$ nums.length ==== threshold.length

  • 1≤n≤1051 \leq n \leq 10^5

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

  • 1≤1 \leq threshold[i] ≤n\leq n