codeforces-670d1Magic Powder-1
Time Limit: 1000MS |
|
Memory Limit: 262144KB |
|
64bit IO Format: %i64d &%i64u |
Submit Status
Description
This problem are given in and versions that differ only by constraints. If you can solve this problem in large constraints and 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 on the morning, Apollinaria decided to bake cookies. To bake one cookie, she needsn ingredients, and for each ingredient she knows the valueai -how many grams of this ingredient one needs to bake a cookie. To prepare one cookie Apollinaria needs to use alln ingredients.
Apollinaria has bi gram of theI-th ingredient. Also She has K grams of a magic powder. Each gram of magic powder can is turned to exactly1 gram of any of the N ingredients and can is used for Baking cookies.
Your task is to determine the maximum number of cookies, which Apollinaria are able to bake using the ingredients that she Has and the magic powder.
Input
The first line of the input contains the positive integers n and K (1?≤? N,? k≤?1000)-the number of ingredients and the number of grams of the magic powder.
The second line contains the sequence a 1,? A 2,?...,? A n (1?≤? A i ? ≤?1000 ), where the i -th number is equal to the number of grams of The i -th ingredient, needed to Bake one cookie.
The third line contains the sequence b1,? b2,?...,? bn (1?≤? ) bi? ≤?1000), where the I-th number is equal to the number of grams of thei< /c14>-th ingredient, which Apollinaria has.
Output
Print the maximum number of cookies, which Apollinaria would be a able to bake using the ingredients that she have and the mag IC Powder.
Sample Input
Input
3 12 1 411 3 16
Output
4
Input
4 34 3 5 611 12 14 20
Output
3
Sample Output
Hint
Source
Codeforces Round #350 (Div. 2)//test instructions: input n,m; M means the number of magical elements, each magical element can be transformed into any other element, which means that the production of biscuits requires n elements, and the number of each element required to make a cookie is a[i], and now gives you the number of each element b[i], ask you how many biscuits can be produced? Idea: Because n is 1000, so direct simulation, up to 1000*1000;
CODEFORCES-670D1 Magic Powder-1 (analog)