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