Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Coins You Can Get

med
30 min
Try to solve the Maximum Number of Coins You Can Get problem.

Statement

There are 3n3n piles of coins of varying size, represented by an integer array piles.

You, Alice, and Bob take turns collecting piles according to the following rules:

  • In each round, you choose any 33 piles of coins.

  • Alice picks the pile containing the maximum number of coins.

  • You pick the pile containing the next maximum number of coins.

  • Bob picks the remaining pile.

  • This process repeats until no piles of coins remain.

Return the maximum number of coins that you can collect.

Constraints:

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

  • piles.length \\% 3 = 0

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Coins You Can Get

med
30 min
Try to solve the Maximum Number of Coins You Can Get problem.

Statement

There are 3n3n piles of coins of varying size, represented by an integer array piles.

You, Alice, and Bob take turns collecting piles according to the following rules:

  • In each round, you choose any 33 piles of coins.

  • Alice picks the pile containing the maximum number of coins.

  • You pick the pile containing the next maximum number of coins.

  • Bob picks the remaining pile.

  • This process repeats until no piles of coins remain.

Return the maximum number of coins that you can collect.

Constraints:

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

  • piles.length \\% 3 = 0

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