Tap here to switch tabs
Problem
Submissions

Problem: Remove Stones to Minimize the Total

med
30 min
Try to solve the Remove Stones to Minimize the Total problem.

Statement

You are given an integer array piles, where piles[i] represents the number of stones in the iextthi^{ ext{th}} pile, and an integer k.

You must perform the following operation exactly k times:

Choose any pile piles[i] and remove ⌊\lfloor piles[i] /2⌋/ 2 \rfloor stones from it.

Return the minimum possible total number of stones remaining after performing the operation k times.

Note: ⌊x⌋\lfloor x \rfloor denotes the floor function, representing the greatest integer less than or equal to xx. You can apply the operation to the same pile multiple times.

Constraints:

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

  • 1≤1 \leq piles[i] ≤104\leq 10^4

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Remove Stones to Minimize the Total

med
30 min
Try to solve the Remove Stones to Minimize the Total problem.

Statement

You are given an integer array piles, where piles[i] represents the number of stones in the iextthi^{ ext{th}} pile, and an integer k.

You must perform the following operation exactly k times:

Choose any pile piles[i] and remove ⌊\lfloor piles[i] /2⌋/ 2 \rfloor stones from it.

Return the minimum possible total number of stones remaining after performing the operation k times.

Note: ⌊x⌋\lfloor x \rfloor denotes the floor function, representing the greatest integer less than or equal to xx. You can apply the operation to the same pile multiple times.

Constraints:

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

  • 1≤1 \leq piles[i] ≤104\leq 10^4

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