Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Sum of K Selected Elements

med
30 min
Try to solve the Maximum Total Sum of K Selected Elements problem.

Statement

You are given an integer array nums and two integers k and mul.

You need to select exactly k elements from nums and choose the order in which to process them.

For each selected element, you can perform one of the following operations:

  • Multiply the element by the current value of mul, add the resulting product to the total sum, and then decrease mul by 11.

  • Add the element directly to the total sum without modifying mul.

Return the maximum possible total sum that can be obtained after processing all k selected elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length

  • 1≤1 \leq mul ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Sum of K Selected Elements

med
30 min
Try to solve the Maximum Total Sum of K Selected Elements problem.

Statement

You are given an integer array nums and two integers k and mul.

You need to select exactly k elements from nums and choose the order in which to process them.

For each selected element, you can perform one of the following operations:

  • Multiply the element by the current value of mul, add the resulting product to the total sum, and then decrease mul by 11.

  • Add the element directly to the total sum without modifying mul.

Return the maximum possible total sum that can be obtained after processing all k selected elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length

  • 1≤1 \leq mul ≤105\leq 10^5