Festival
문제
Nayra is at a festival playing a game where the grand prize is a trip to Laguna Colorada. The game consists of using tokens to buy coupons. Buying a coupon may result in additional tokens. The goal is to get as many coupons as possible.
She starts the game with tokens. There are coupons, numbered from to . Nayra has to pay tokens () to buy coupon (and she must have at least tokens before the purchase). She can buy each coupon at most once.
Moreover, each coupon () is assigned a type, denoted by , which is an integer between and , inclusive. After Nayra buys coupon , the remaining number of tokens she has gets multiplied by . Formally, if she has tokens at some point of the game, and buys coupon (which requires ), then she will have tokens after the purchase.
Your task is to determine which coupons Nayra should buy and in what order, to maximize the total number of coupons she has at the end. If there is more than one sequence of purchases that achieves this, you may report any one of them.