#K40337. Minimum Packs for Taco Recipes
Minimum Packs for Taco Recipes
Minimum Packs for Taco Recipes
Alice loves tacos and enjoys experimenting with different recipes. She has prepared n recipes, each requiring m ingredients. For each ingredient, the required amount in each recipe is provided, and each pack of the ingredient contains a fixed number of units.
Your task is to determine the minimum number of packs for each ingredient so that Alice can make any of her recipes without ever running short. For ingredient j, let \(R_j\) be the maximum amount required among all recipes and \(p_j\) be the number of units in one pack. Then, the minimum number of packs required is given by:
[ \lceil \frac{R_j}{p_j} \rceil ]
Note that if an ingredient is not needed in any recipe (i.e. \(R_j=0\)), then no pack is required.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers n and m, where n is the number of recipes and m is the number of ingredients.
- The next n lines each contain m space-separated integers. The j-th integer on the i-th line represents the amount of the j-th ingredient required for the i-th recipe.
- The final line contains m space-separated integers, where the j-th integer is the number of units in one pack for the j-th ingredient.
outputFormat
Output a single line to standard output (stdout) containing m space-separated integers. Each integer indicates the minimum number of packs required for the corresponding ingredient.## sample
3 3
3 2 5
4 1 2
1 3 4
2 1 3
2 3 2