Communication System
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 22380   Accepted: 7953

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. 

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.

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. 

Sample Input

1 3
3 100 25 150 35 80 25
2 120 80 155 40
2 100 100 120 110

Sample Output

0.649

Source

Tehran 2002, First Iran Nationwide Internet Programming Contest
 
投降的题...
 
题意:
    给出n样零件,及每样零件的都有b[i]个厂生产,有带宽b和价格p两个值。求全部零件(每样一件) min(b)/sum(p) 的最大值。
 
枚举:
    对带宽进行枚举,选出全部零件的最大及最小带宽,然后进行枚举,每个循环选出符合条件的价格的和,得出ans再进行比较,得到最优解。
 //232K    47MS    C++    1164B    2014-05-07 19:16:42
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node{
int b;
int p;
}a[][];
int b[];
int n;
inline int Max(int x,int y)
{
return x>y?x:y;
}
inline int Min(int x,int y)
{
return x<y?x:y;
}
int main(void)
{
int t,m;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int ln=0x7ffffff,rn=;
for(int i=;i<n;i++){
scanf("%d",&b[i]);
for(int j=;j<b[i];j++){
scanf("%d%d",&a[i][j].b,&a[i][j].p);
ln=Min(ln,a[i][j].b);
rn=Max(rn,a[i][j].b);
}
}
double ans=;
for(int i=ln;i<=rn;i++){
int sminn=;
for(int j=;j<n;j++){
int minn=0x7ffffff;
for(int k=;k<b[j];k++){
if(a[j][k].b>=i && minn>a[j][k].p)
minn=a[j][k].p;
}
sminn+=minn;
}
ans=ans>(i*1.0/sminn)?ans:(i*1.0/sminn);
//printf("*****%lf\n",ans);
}
printf("%.3lf\n",ans);
}
return ;
}

poj 1018 Communication System (枚举)的更多相关文章

  1. poj 1018 Communication System 枚举 VS 贪心

    Communication System Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21631   Accepted:  ...

  2. POJ 1018 Communication System(树形DP)

    Description We have received an order from Pizoor Communications Inc. for a special communication sy ...

  3. POJ 1018 Communication System(贪心)

    Description We have received an order from Pizoor Communications Inc. for a special communication sy ...

  4. poj 1018 Communication System

    点击打开链接 Communication System Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21007   Acc ...

  5. POJ 1018 Communication System (动态规划)

    We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...

  6. POJ 1018 Communication System 贪心+枚举

    看题传送门:http://poj.org/problem?id=1018 题目大意: 某公司要建立一套通信系统,该通信系统需要n种设备,而每种设备分别可以有m个厂家提供生产,而每个厂家生产的同种设备都 ...

  7. POJ 1018 Communication System(DP)

    http://poj.org/problem?id=1018 题意: 某公司要建立一套通信系统,该通信系统需要n种设备,而每种设备分别可以有m1.m2.m3.....mn个厂家提供生产,而每个厂家生产 ...

  8. POJ 1018 Communication System 题解

    本题一看似乎是递归回溯剪枝的方法.我一提交,结果超时. 然后又好像是使用DP,还可能我剪枝不够. 想了非常久,无奈忍不住偷看了下提示.发现方法真多.有贪心,DP,有高级剪枝的.还有三分法的.八仙过海各 ...

  9. poj 1018 Communication System_贪心

    题意:给你n个厂,每个厂有m个产品,产品有B(带宽),P(价格),现在要你求最大的 B/P 明显是枚举,当P大于一定值,B/P为零,可以用这个剪枝 #include <iostream> ...

随机推荐

  1. 苏州Uber优步司机奖励政策(4月2日~4月3日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  2. 每天看一片代码系列(三):codepen上一个音乐播放器的实现

    今天我们看的是一个使用纯HTML+CSS+JS实现音乐播放器的例子,效果还是很赞的: codePen地址 HTML部分 首先我们要思考一下,一个播放器主要包含哪些元素.首先要有播放的进度信息,还有播放 ...

  3. kalibr论文阅读笔记

    单目相机IMU标定 该论文将相机IMU标定分为两个大方面: 一. 使用基函数来估计时间偏差 二. 相机和IMU的空间位置转换 校准变量:重力.外参旋转和平移.时钟偏移.IMU位姿.加速度计偏置.陀螺仪 ...

  4. thinkphp5使用workerman的定时器定时任务在某一个时间执行

    1.首先通过 composer 安装workerman,在thinkphp5完全开发手册的扩展->coposer包->workerman有详细说明: #在项目根目录执行以下指令compos ...

  5. Objective-C Block数据类型 @protocol关键字

    Block数据类型 Block封装了一段代码 可以在任何时候执行 Block可以作为函数参数或者函数的返回值 而其本身又可以带输入参数或返回值 苹果官方建议尽量多用Block 在多线程 异步任务 集合 ...

  6. leetcode-回文链表

    请判断一个链表是否为回文链表. 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 进阶:你能否用 O(n) 时间复杂 ...

  7. 文本分类-TextCNN

    简介 TextCNN模型是由 Yoon Kim提出的Convolutional Naural Networks for Sentence Classification一文中提出的使用卷积神经网络来处理 ...

  8. CDH/Hadoop 5.15 installation steps

    I will talk the main steps to install CDH 5.15 on Linux(CENT OS 6.10).  The installation method is M ...

  9. 学霸系统PipeLine功能规格说明书

    学霸系统PipeLine功能规格说明书共分为以下三部分: 1.产品面向用户群体 2.用户使用说明 3.产品功能具体实现 1.产品面向用户群体 我们这组的项目并不是传统意义上能发布并进行展示的项目,因此 ...

  10. CSS3制作各种形状图像(转)

    CSS3制作各种形状图像 浏览:1417 | 更新:2015-05-24 14:43 | 标签:css 1 2 3 4 5 6 7 分步阅读 圆形-椭圆形-三角形-倒三角形=左三角形-右三角形-菱形- ...