POJ 1018/TJU 1258 Communication System

来源:互联网 发布:电子表格数据库 编辑:程序博客网 时间:2024/06/03 23:38
Communication System
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 19834 Accepted: 7032

Description

We have received an order from Pizoor Communications Inc. for a special communication system. The system consists of several devices. For each device, we are free to choose from several manufacturers. Same devices from two manufacturers differ in their maximum bandwidths and prices. 
By overall bandwidth (B) we mean the minimum of the bandwidths of the chosen devices in the communication system and the total price (P) is the sum of the prices of all chosen devices. Our goal is to choose a manufacturer for each device to maximize B/P. 

我们已经Pizoor通信接到命令,为了一个特殊的通信系统。该系统由多台设备。对于每个设备,我们从几个制造商中可以自由选择作为供货商。两家制造商的同一设备的最大带宽和价格不同。

通过(B)的总带宽,我们估计通信系统中的带宽最小值;所选择的设备的总的价格(P)是所有选定的设备的价格的总和。我们的目标是选取每个设备的制造商选择,最大限度地提高B / P.

Input

The first line of the input file contains a single integer t (1 ≤ t ≤ 10), the number of test cases, followed by the input data for each test case. Each test case starts with a line containing a single integer n (1 ≤ n ≤ 100), the number of devices in the communication system, followed by n lines in the following format: the i-th line (1 ≤ i ≤ n) starts with mi (1 ≤ mi ≤ 100), the number of manufacturers for the i-th device, followed by mi pairs of positive integers in the same line, each indicating the bandwidth and the price of the device respectively, corresponding to a manufacturer.
输入文件的第一行包含一个整数T(1≤T≤10),这个是测试用例的数量,接着是为每个测试用例的输入数据。每个测试案例开始是含有一个单一的整数n(1≤N≤100)的一个界限,这个是在所述通信系统中的设备的数目;然后由n行的格式如下:第(1≤i≤N)i行的mi(1≤mi≤100)的开始,这个数是指第i个的移动设备制造商的数目,然后由在同一行中的正整数mi对,每个分别指示的带宽和该装置的价格,对应于制造商。
Output
Your program should produce a single line for each test case containing a single number which is the maximum possible B/P for the test case. Round the numbers in the output to 3 digits after decimal point. 
你的程序应该为每个测试案例的单个数值产生一个单一的线(line),它是最大可能的B / P的测试案例。四舍五入的数字输出到小数点后3位。
Sample Input
1 33 100 25 150 35 80 252 120 80 155 402 100 100 120 110

Sample Output

0.649

Source

Tehran 2002, First Iran Nationwide Internet Programming Contest