Жишээ тэстүүд

Оролт
3 1
2 1 4
11 3 16
Гаралт
4
Оролт
4 3
4 3 5 6
11 12 14 20
Гаралт
3

Тэмдэглэл

In the first sample it is profitably for Apollinaria to make the existing 1 gram of her magic powder to ingredient with the index 2, then Apollinaria will be able to bake 4 cookies.

In the second sample Apollinaria should turn 1 gram of magic powder to ingredient with the index 1 and 1 gram of magic powder to ingredient with the index 3. Then Apollinaria will be able to bake 3 cookies. The remaining 1 gram of the magic powder can be left, because it can't be used to increase the answer.