Tap here to switch tabs
Problem
Submissions

Problem: Maximum Sum With Exactly K Elements

med
30 min
Try to solve the Maximum Sum With Exactly K Elements problem.

Statement

You are given a 00 indexed integer array nums and an integer k. You must perform the following operation exactly k times to maximize your total score:

11. Choose an element m from nums.
22. Remove the selected element m from nums.
33. Insert a new element with the value m +1+ 1 into nums.
44. Add m to your total score.

Your initial score is 00. Return the maximum total score achievable after performing the operation exactly k times.

Constraints:

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

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq k ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Sum With Exactly K Elements

med
30 min
Try to solve the Maximum Sum With Exactly K Elements problem.

Statement

You are given a 00 indexed integer array nums and an integer k. You must perform the following operation exactly k times to maximize your total score:

11. Choose an element m from nums.
22. Remove the selected element m from nums.
33. Insert a new element with the value m +1+ 1 into nums.
44. Add m to your total score.

Your initial score is 00. Return the maximum total score achievable after performing the operation exactly k times.

Constraints:

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

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq k ≤100\leq 100