?
ProblemG
CrimeWave – The Sequel
Input: StandardInput
?
Output: StandardOutput
TimeLimit: 2 Seconds
?
n bankshave been robbed this fine day. m (greater than orequal to n) police cruisers are on duty at variouslocations in the city. n of the cruisers should bedispatched, one to each of the banks, so as to minimize the averagetime of arrival at the n banks.
?
Input
Theinput file contains several sets of inputs. The description of eachset is given below:
Thefirst line of input contains 0 < n <= m <=20. n lines follow, each containing m positivereal numbers: the travel time for cruiser m to reachbank n.
Inputis terminated by a case where m=n=0. This case should notbe processed.
Output
Foreach set of input output a single number: the minimum average traveltime, accurate to 2 fractional digits.
SampleInput Outputfor Sample Input
3 4
10.0 23.0 30.0 40.0
5.0 20.0 10.0 60.0
18.0 20.0 20.0 30.0 00 |
13.33 |
Problemsetter: GordonCormack, EPS
题意:
有m个警察,派n个警察到n个银行,给出每个警察到各银行的时间,求最小的平均时间。
分析:
平均乘上n就是总时间,也就是要最小化总时间,那么用费用流就可以解决问题。各银行向每个警察连边,容量1,费用为时间;增加源点,源点向各银行连边,容量1,费用0;增加汇点,警察向汇点连边,容量1,费用0。在图中跑费用流就行。
这题最恶心的地方在于保留小数,结果加上eps再输出。这里涉及到保留小数方法,是用传统的四舍五入还是用银行家舍入?都不知道以后涉及到小数的输出要怎么搞了,这种东西就该spj啊。
?
?
/*
*
* Author : fcbruce
*
* Date : 2014-09-05 20:37:26
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
?