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> ...
随机推荐
- 北京Uber优步司机奖励政策(12月29日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- Android AOSP 编译sdk
首先你要有AOSP 工程. 然后执行下面的命令编译sdk. //运行下面的命令得到编译环境 source build/envsetup.sh lunch sdk make sdk 最后文件输出在哪个位 ...
- CakePHP中回调函数的使用
我们知道模型主要是用来处理数据的,有时我们想在模型操作之前或之后做一些额外逻辑处理,这时候就可以使用回调函数. 回调函数有很多种,beforeFind,afterFind,beforeValidate ...
- 下载Web微信视频
1. 用浏览器(我用Chrome)登录web微信(wx.qq.com) 2. 这个时候如果有人发视频,可以点开播放.用F12打开chrome的调试平台,查看视频源的URL(绿色框的src内容) 3. ...
- hdu1045Fire Net(经典dfs)
Fire Net Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- python爬虫实例大全
WechatSogou [1]- 微信公众号爬虫.基于搜狗微信搜索的微信公众号爬虫接口,可以扩展成基于搜狗搜索的爬虫,返回结果是列表,每一项均是公众号具体信息字典. DouBanSpider [2]- ...
- python 定位文件目录
经常有引用文件的地方,所以整理了一下如何定位文件目录的方法 定位当前文件的目录 import os file_path = os.path.dirname(__file__) 定位当前文件的父目录 i ...
- Python 关键字参数和可变参数
关键字参数 如果你有一些具有许多参数的函数,而你又希望只对其中的一些进行指定,那么你可以通过命名它们来给这些参数赋值——这就是python关键字参数(Keyword Arguments)——我们使用命 ...
- 【转】MMO即时战斗:地图角色同步管理和防作弊实现
---转自CSDN 一.前言 无论是端游.页游.手游如果是采用了MMO即时战斗游戏模式,基本都会遇到同屏多角色实时移动.释放技能.战斗等场景,于是自然也需要实现如何管理同屏内各种角色的信息同步:例如角 ...
- Dreamweaver CS5网页制作教程
说到Dreamweaver这个网页制作神器,不由得想起在学校里上的选修课,那是的我们只知道 table 布局,只知道构建网站最方便的是使用“所见即所得”编辑器.回忆一下,真的是很怀旧啊! 虽说咱现在大 ...