Baker

first, consider how to solve for baker 1. let’s say the currently active orders are at times 𝑑1,𝑑2,…,𝑑𝑛in increasing order. first, note that if we want to fulfill all 𝑛 orders, it is both necessary and sufficient that 𝑑𝑖β‰₯𝑖 for all 𝑖. from this, it follows that the maximum number of orders we can fulfill is 𝑛+min(π‘‘π‘–βˆ’π‘–).

in general, baker π‘˜ can fulfill

𝑛+⌊min(π‘‘π‘–βˆ’π‘˜π‘–)π‘˜βŒ‹

orders. we can see this problem as finding the minimum of lines π‘‘π‘–βˆ’π‘–π‘₯ at π‘₯=π‘˜. for general queries, note that the active set of indices for a given query is always a contiguous range. therefore the problem reduces to the following:

we are given a collection of lines where line 𝑖 has slope 𝑖. for π‘ž queries (𝑙,π‘Ÿ,π‘˜), find the minimum of 𝑓(π‘˜) among lines [𝑙,π‘Ÿ].

this can be solved with divide and conquer in π’ͺ((π‘ž+π‘š)logπ‘š) time by noting that the lines are already sorted by slope, and therefore convex hull can be run in linear time.

https://qoj.ac/submission/2189261