A bakery needs to bake a batch of loaves of various recipes. There are K different recipe types, indexed from 1 to K. For each recipe i, the bakery must bake cnt[i] loaves. Each loaf takes exactly one oven slot and the oven slots are processed sequentially (slot 1, slot 2, slot 3, and so on).
The recipes are partitioned into G independent groups, numbered from 1 to G. The group of recipe i is given by grp[i]. Recipes in the same group share physical tins, which introduces a cooldown constraint:
g is baked at slot x, the next loaf of group g can be baked at slot y, where y - x >= n + 1.ceil(n / 2) slots. That is, for this pair, y - x >= ceil(n / 2) + 1. The choice of whether and where to use the blast chiller is independent for each group.Slots can be used to bake loaves of different groups, or they can be left idle.
Find the minimum total number of slots (i.e., the index of the last active slot, assuming we start at slot 1) required to bake all loaves of all recipes.
Input Format
K, denoting the number of recipe types.n, denoting the minimum cooldown slots required between consecutive loaves of the same group.G, denoting the number of independent groups.MotorQ • Pending