这个问题有两个版本,它们仅在约束上有所不同。如果可以在较大的约束中解决此问题,则可以为两个版本编写一个解决方案。如果在较大的约束中发现问题太难,则可以仅将解决方案写入简化版本。
早晨醒来,阿波利纳利亚决定烤饼干。为了烤一块饼干,她需要n种原料,对于每一种原料,她知道其价值ai——烤一块饼干需要多少克这种原料。为了准备一块饼干,Apollinaria需要使用所有n种材料。
阿波利纳里亚含有第i种成分bi克。她还有k克的魔法粉。每克神奇粉末可以正好变成 1 克 n 种成分中的任何一种,可用于烘焙饼干。
你的任务是确定饼干的最大数量,阿波利纳里亚能够使用她拥有的成分和神奇的粉末烘烤这些饼干。
This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too difficult in large constraints, you can write solution to the simplified version only.
Waking up in the morning, Apollinaria decided to bake cookies. To bake one cookie, she needs n ingredients, and for each ingredient she knows the value ai− how many grams of this ingredient one needs to bake a cookie. To prepare one cookie Apollinaria needs to use all n ingredients.
Apollinaria has bi gram of the i-th ingredient. Also she has k grams of a magic powder. Each gram of magic powder can be turned to exactly 1 gram of any of the n ingredients and can be used for baking cookies.
Your task is to determine the maximum number of cookies, which Apollinaria is able to bake using the ingredients that she has and the magic powder.
3 1 2 1 4 11 3 16
4
4 3 4 3 5 6 11 12 14 20
3
3 1
2 1 4
11 3 16
4