Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Reward Using Operations II

Try to solve the Maximum Total Reward Using Operations II problem.

Statement

You are given an integer array rewardValues of size nn.

Initially, your total reward x is 00, and all indices are unmarked. You can perform the following operation any number of times:

  1. Pick an unmarked index i from 00 to n−1n - 1 such that rewardValues[i] > x.

  2. Add rewardValues[i] to your current total reward x (i.e., x = x + rewardValues[i]).

  3. Mark the index i.

Return the maximum total reward x you can achieve by performing the operations optimally.

Constraints:

  • 1≤1 \leq rewardValues.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq rewardValues[i] ≤5imes104\leq 5 imes 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Reward Using Operations II

Try to solve the Maximum Total Reward Using Operations II problem.

Statement

You are given an integer array rewardValues of size nn.

Initially, your total reward x is 00, and all indices are unmarked. You can perform the following operation any number of times:

  1. Pick an unmarked index i from 00 to n−1n - 1 such that rewardValues[i] > x.

  2. Add rewardValues[i] to your current total reward x (i.e., x = x + rewardValues[i]).

  3. Mark the index i.

Return the maximum total reward x you can achieve by performing the operations optimally.

Constraints:

  • 1≤1 \leq rewardValues.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq rewardValues[i] ≤5imes104\leq 5 imes 10^4