poj 1018 Communication System (枚举)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 22380 | Accepted: 7953 |
Description
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
Output
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
//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 (枚举)的更多相关文章
- poj 1018 Communication System 枚举 VS 贪心
Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21631 Accepted: ...
- POJ 1018 Communication System(树形DP)
Description We have received an order from Pizoor Communications Inc. for a special communication sy ...
- POJ 1018 Communication System(贪心)
Description We have received an order from Pizoor Communications Inc. for a special communication sy ...
- poj 1018 Communication System
点击打开链接 Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21007 Acc ...
- POJ 1018 Communication System (动态规划)
We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...
- POJ 1018 Communication System 贪心+枚举
看题传送门:http://poj.org/problem?id=1018 题目大意: 某公司要建立一套通信系统,该通信系统需要n种设备,而每种设备分别可以有m个厂家提供生产,而每个厂家生产的同种设备都 ...
- POJ 1018 Communication System(DP)
http://poj.org/problem?id=1018 题意: 某公司要建立一套通信系统,该通信系统需要n种设备,而每种设备分别可以有m1.m2.m3.....mn个厂家提供生产,而每个厂家生产 ...
- POJ 1018 Communication System 题解
本题一看似乎是递归回溯剪枝的方法.我一提交,结果超时. 然后又好像是使用DP,还可能我剪枝不够. 想了非常久,无奈忍不住偷看了下提示.发现方法真多.有贪心,DP,有高级剪枝的.还有三分法的.八仙过海各 ...
- poj 1018 Communication System_贪心
题意:给你n个厂,每个厂有m个产品,产品有B(带宽),P(价格),现在要你求最大的 B/P 明显是枚举,当P大于一定值,B/P为零,可以用这个剪枝 #include <iostream> ...
随机推荐
- 下载地图瓦片(包括各种格式的,Openstreetmap,googlemap, bingmap)
参考第三方开源库Brutile 个人的程序托管在github上
- 北京Uber优步司机奖励政策(1月24日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- zipaligin的使用介绍
近来一直在做APK反编译和重编译的工作,针对一些apk需要放入一些相应的文件,(当然这里不涉及非法盈利,都是有合约的),在对一些包打包以后,发现可以通过一个叫做zipalign的工具进行优化,对于这个 ...
- hdu1907John(反nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- php单例模式和工厂模式
单例模式:防止重复实例化,避免大量的new操作,减少消耗系统和内存的资源,使得有且仅有一个实例对象 header("Content-type: text/html; charset=utf- ...
- 接口测试工具postman(五)批量执行测试用例
1.准备好测试用例及相关数据 2.点击Run按钮 3.选择运行collection或者folder 4.运行完成
- Jenkis 无法下载插件问题解决
在新机器上安装jenkins后,安装插件报如下错误 sun.security.provider.certpath.SunCertPathBuilderException: unable to find ...
- Python|一文简单看懂 深度&广度 优先算法
一.前言 以后尽量每天更新一篇,也是自己的一个学习打卡!加油!今天给大家分享的是,Python里深度/广度优先算法介绍及实现. 二.深度.广度优先算法简介 1. 深度优先搜索(DepthFirstSe ...
- ObjectMapper的使用
Jackson ObjectMapper类 ObjectMapper类是Jackson库的主要类它提供一些功能将Java对象转换成JSON结构,反之亦然它使用JsonParser和JsonGenera ...
- 牛客网暑期ACM多校训练营(第五场):F - take
链接:牛客网暑期ACM多校训练营(第五场):F - take 题意: Kanade有n个盒子,第i个盒子有p [i]概率有一个d [i]大小的钻石. 起初,Kanade有一颗0号钻石.她将从第1到第n ...