Official algorithmic problem description and constraints.
You're playing your favorite video game: Pekómon!
The objective of the game is, of course, to "Catch Them All".
There are 𝑁 different Pekómon in the game. The 𝑖th of them has a catching difficulty of 𝐴𝑖
To catch these Pekómon, you must use Pekóballs. There are two types of Pekóballs available to you:
Find the minimum number of coins you need to spend on buying Pekóballs, so that you can catch all 𝑁 Pekómon.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.