Burgers
InterviewTime limit1sMemory limit1024 MB
Given stock x_i and the per-ingredient needs a_i and b_i of two burger recipes, find the maximum number of burgers that can be made.
- Level
Medium5 of 10
- Topics
- Binary search, Math, Greedy
- Solved
- No attempts yet
Problem
Kai the lobster is starting a burger chain. He has ingredients, labelled from to . For each ingredient , he has portions of ingredient .
He has two recipes for burgers. For each ingredient , the first recipe requires portions of ingredient , and the second recipe requires portions of ingredient .
Find the maximum total number of burgers Kai can make.
Input
The first line contains one integer , the number of different ingredients.
The second line contains integers , the total number of portions Kai has of each ingredient.
The third line contains integers , the number of portions of each ingredient for the first recipe.
The fourth line contains integers , the number of portions of each ingredient for the second recipe.
Output
Output a single integer on a single line, the largest number of burgers Kai can make.
Constraints