Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Coins You Can Get

Maximum Number of Coins You Can Get gives three times as many piles as rounds. Choose three each round and return the most coins you can collect while Alice takes the largest and Bob the last.

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

Maximum Number of Coins You Can Get gives three times as many piles as rounds. Choose three each round and return the most coins you can collect while Alice takes the largest and Bob the last.

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