#P4015. 运输问题
运输问题
Description
Company has warehouses and retail stores. The -th warehouse has units of goods; the -th retail store needs units of goods.
The supply and demand are balanced, i.e., .
The cost to transport each unit of goods from the -th warehouse to the -th retail store is .
Design a transportation plan to ship all goods from the warehouses to the retail stores so that the total transportation cost is minimized.
Input Format
Line 1 contains 2 positive integers and , representing the number of warehouses and retail stores, respectively.
The next line contains positive integers , where the -th warehouse has units of goods.
The following line contains positive integers , where the -th retail store requires units of goods.
The next lines each contain integers, representing the per-unit transportation cost from the -th warehouse to the -th retail store.
Output Format
Output two lines: the minimum total transportation cost and the maximum total transportation cost.
2 3
220 280
170 120 210
77 39 105
150 186 122
48500
69140
Hint
.
Translated by ChatGPT 5
京公网安备 11011102002149号