poj 2516
来源:互联网 发布:mac终端怎么保存退出 编辑:程序博客网 时间:2024/05/07 03:19
Minimum Cost
Time Limit: 4000MS Memory Limit: 65536KTotal Submissions: 8085 Accepted: 2653
Description
Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K different kinds of goods (marked from 1 to K). Once shopkeepers order goods, Dearboy should arrange which supply place provide how much amount of goods to shopkeepers to cut down the total cost of transport.
It's known that the cost to transport one unit goods for different kinds from different supply places to different shopkeepers may be different. Given each supply places' storage of K kinds of goods, N shopkeepers' order of K kinds of goods and the cost to transport goods for different kinds from different supply places to different shopkeepers, you should tell how to arrange the goods supply to minimize the total cost of transport.
It's known that the cost to transport one unit goods for different kinds from different supply places to different shopkeepers may be different. Given each supply places' storage of K kinds of goods, N shopkeepers' order of K kinds of goods and the cost to transport goods for different kinds from different supply places to different shopkeepers, you should tell how to arrange the goods supply to minimize the total cost of transport.
Input
The input consists of multiple test cases. The first line of each test case contains three integers N, M, K (0 < N, M, K < 50), which are described above. The next N lines give the shopkeepers' orders, with each line containing K integers (there integers are belong to [0, 3]), which represents the amount of goods each shopkeeper needs. The next M lines give the supply places' storage, with each line containing K integers (there integers are also belong to [0, 3]), which represents the amount of goods stored in that supply place.
Then come K integer matrices (each with the size N * M), the integer (this integer is belong to (0, 100)) at the i-th row, j-th column in the k-th matrix represents the cost to transport one unit of k-th goods from the j-th supply place to the i-th shopkeeper.
The input is terminated with three "0"s. This test case should not be processed.
Then come K integer matrices (each with the size N * M), the integer (this integer is belong to (0, 100)) at the i-th row, j-th column in the k-th matrix represents the cost to transport one unit of k-th goods from the j-th supply place to the i-th shopkeeper.
The input is terminated with three "0"s. This test case should not be processed.
Output
For each test case, if Dearboy can satisfy all the needs of all the shopkeepers, print in one line an integer, which is the minimum cost; otherwise just output "-1".
Sample Input
1 3 3 1 1 1 0 1 1 1 2 2 1 0 1 1 2 3 1 1 1 2 1 1 1 1 1 3 2 20 0 0 0
Sample Output
4 -1
Source
POJ Monthly--2005.07.31, Wang Yijie
分析:这题既可以用KM算法,又可以用最大流最小费用。。。两种算法我都不会耶,于是。。。拿来当练习。。。
KM算法:
最小费用流:
- poj 2516
- poj 2516
- poj 2516
- POJ 2516
- poj 2516
- poj 2516
- POJ 2516 Minimum Cost
- poj 2516 Mininum Cost
- Poj 2516 Minimum Cost
- POJ 2516 Minimum Cost
- POJ-2516-Minimum Cost
- poj 2516 Minimum Cost
- POJ 2516 Minimum Cost
- POJ 2516 Minimum Cost
- POJ 2516 Minimum Cost
- POJ 2516 Minimum Cost
- poj 2516 Minimum Cost
- POJ-2516-Minimum Cost
- CSDN
- 关于有窗口句柄和无窗口句柄的截图
- 原来什么都是浮云
- 用单件模式 实现全局变量
- 转一篇文章,以便在后续文章中讲解——开源gis项目Mitab在C#中的使用方法
- poj 2516
- 大家节假日去爬华山,没去过可是一生的遗憾啊!
- 2008 BUPT 计算机复试上机题
- 数据库连接问题
- awk使用手册
- 金山毒霸通行证申请小助手的原理揭秘
- java密码加密
- ARM编译器的semihosting
- 最快速度找到内存泄漏(不得不转的好文章)