D2. Magic Powder - 2
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Input
The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109) — the number of ingredients and the number of grams of the magic powder.
Th

本文探讨了二分查找算法在游戏开发中的实际应用,通过实例展示了如何利用二分查找解决游戏逻辑中的问题,提供了游戏开发者进行优化和效率提升的新思路。
最低0.47元/天 解锁文章
6万+

被折叠的 条评论
为什么被折叠?



