#P5950. Sticker Collection
Sticker Collection
Sticker Collection
Charles bought many boxes of stickers. Each box contains stickers with digits from \(0\) to \(9\). In every box, the counts of stickers for each digit are exactly \(i_0, i_1, \dots, i_9\) respectively, where each \(i_d\) does not exceed 9. Initially all boxes are closed. In the process, Charles opens one new box for each number he wants to form. After opening a box, he uses the stickers from all boxes opened so far (stickers are not consumed, they are reusable) to form a positive integer.
The procedure is as follows: When forming the 1st number, he opens box 1 and uses its stickers to form the number 1. Then for the 2nd number, he opens box 2 (so that a total of 2 boxes are available) and, using all available stickers, forms the number 2. In general, when attempting to form the number \(N\), he will have opened exactly \(N\) boxes. However, if for some number \(N\) the stickers available in the \(N\) boxes are insufficient to cover the digit counts required to write \(N\> (in its usual decimal representation without extra leading zeros), then Charles stops working and no further numbers can be formed.
More formally, if we let \(F_d(N)\) be the total number of stickers with digit \(d\) needed to form all numbers from \(1\) to \(N\) (i.e. the cumulative frequency of digit \(d\) in the decimal representations of \(1,2,\dots, N\)), and note that after opening \(N\) boxes there are exactly \(N \times i_d\) stickers with digit \(d\) available, then Charles is able to form \(N\) if and only if \[ N \times i_d \ge F_d(N)\quad \text{for each digit } d=0,1,\dots,9. \]
Your task is: given \(i_0,i_1,\dots,i_9\), compute the maximum number of positive integers that Charles can form.
Note: Each integer is written in its usual decimal form (without leading zeros). All formulae are written in \(\LaTeX\) format.
inputFormat
The input consists of a single line with 10 space‐separated integers \(i_0,i_1,\dots,i_9\). Each \(i_d\) (\(0 \le i_d \le 9\)) represents the number of stickers with digit \(d\) in each box.
outputFormat
Output a single integer, which is the maximum number of numbers that Charles can form following the process described above.
sample
1 1 1 1 1 1 1 1 1 1
199990