Official algorithmic problem description and constraints.
You have been offered to play a game. In this game, there are π possible outcomes, and for each of them, you must bet a certain integer amount of coins. In the event that the π-th outcome turns out to be winning, you will receive back the amount of coins equal to your bet on that outcome, multiplied by ππ. Note that exactly one of the π outcomes will be winning.
Your task is to determine how to distribute the coins in such a way that you will come out ahead in the event of any winning outcome. More formally, the total amount of coins you bet on all outcomes must be strictly less than the number of coins received back for each possible winning outcome.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.