Given n drinks, find optimum way to spend money if for each drink the price and the expiration date is given
It’s not very difficult really, assuming we only care about the cost and don’t have any preferences for drinks. 

If we want to make a single order that lasts for n days as cheap as possible, we order the cheapest drink with expiry k, for each 0 &lt;= k &lt; n. That supply costs the cost of the drinks plus d. We can calculate this cost for 1 &lt;= n &lt;= E+1, where E is the longest expiry of any drink. 

If we want drinks for N days, we make 1 or more orders to minimise the total cost. We may assume the orders are ordered by size in descending order (and if we find the best sequence of orders with this restriction, we can rearrange it any way we like). Finding the best orders is now a simple dynamic programming problem. 

If you are looking for something complicated, it’s not needed.