Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Value

Try to solve the Maximum Total Value problem.

Statement

You are given two integer arrays value and decay of equal length, along with an integer m.

You can make at most m selections across the available indices. When you choose an index i:

  • The first time index i is selected, you gain value[i].

  • Each subsequent time index i is selected, the gained value decreases by decay[i]. If index i has previously been selected kk times, choosing it again provides max⁡(0,\max(0, value[i] −k×- k \times decay[i])).

Return the maximum total value you can achieve after at most m selections.

Constraints:

  • 1≤1 \leq value.length == decay.length ≤105\leq 10^5

  • 1≤1 \leq value[i], decay[i] ≤109\leq 10^9

  • 1≤1 \leq m ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Value

Try to solve the Maximum Total Value problem.

Statement

You are given two integer arrays value and decay of equal length, along with an integer m.

You can make at most m selections across the available indices. When you choose an index i:

  • The first time index i is selected, you gain value[i].

  • Each subsequent time index i is selected, the gained value decreases by decay[i]. If index i has previously been selected kk times, choosing it again provides max⁡(0,\max(0, value[i] −k×- k \times decay[i])).

Return the maximum total value you can achieve after at most m selections.

Constraints:

  • 1≤1 \leq value.length == decay.length ≤105\leq 10^5

  • 1≤1 \leq value[i], decay[i] ≤109\leq 10^9

  • 1≤1 \leq m ≤109\leq 10^9