Editorial for COCI '07 Regional #3 Kuhar
Submitting an official solution before solving the problem yourself is a bannable offence.
Let us first solve the following subproblem: how many dollars must we pay to buy  units of some ingredient?
This subproblem is easily solved by trying all possible numbers of large packages and calculating the number of small packages needed to achieve  units. The solution is the smallest cost over all choices for the number of large packages.
Now we can check if we have enough ingredients for  servings of the meal. For each ingredient, we know how many units we need for 
 servings and we can calculate the cost for that many servings using the above algorithm. If we have enough money to buy all needed ingredients, then we can prepare 
 servings.
A solution that increments  while we can prepare 
 servings will score 
 of points. To obtain the full score, use binary search to find the largest 
 such that we can prepare 
 servings.
Comments