#graph805. 餐巾计划问题
餐巾计划问题
Napkin Plan
Problem Source
Network Flow 24 Problems
Problem Description
A restaurant needs a different number of napkins on each of consecutive days. Suppose day needs napkins.
Each day the restaurant may do the following:
- Buy new napkins, at a cost of per napkin.
- Send dirty napkins to the fast laundry, which takes days and costs per napkin.
- Send dirty napkins to the slow laundry, which takes days and costs per napkin.
At the end of each day, the restaurant must decide how many dirty napkins to send to the fast laundry, how many to the slow laundry, and how many to keep for deferred washing. However, the number of clean napkins obtained from laundering plus the number of newly bought napkins each day must meet that day's demand.
Design an algorithm to arrange the napkin usage plan for the days reasonably, so as to minimize the total cost.
Input Format
The first line contains six positive integers $n, c_0, d_1, c_1, d_2, c_2 (1\leq n \leq 800, 1\leq c_i\leq 100)$.
The following lines each contain one integer .
Output Format
Output the minimum total cost for the restaurant to use napkins over the consecutive days.
Sample Input
3 11 2 2 3 1
1
7
5
Sample Output
134
Constraints
, , .
Hint
- This is a classic minimum-cost maximum-flow problem: model each day with a "demand" node (needs clean napkins) and a "dirty" node (receives used napkins), then connect buying, fast laundering, and slow laundering as edges with the appropriate costs and delays.