POJ1018 Communication System
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 26738 | Accepted: 9546 |
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
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
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
/**/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1e8;
const int mxn=;
double ans=;
int f[mxn][];
int b,p;
int n,m;
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
memset(f,,sizeof f);
int i,j;
for(i=;i<;i++)f[][i]=;;
for(i=;i<=n;i++){
scanf("%d",&m);
for(j=;j<=m;j++){
scanf("%d%d",&b,&p);
if(i==)f[][b]=min(f[][b],p);
else{
for(int k=;k<;k++)
f[i][min(k,b)]=min(f[i][min(k,b)],f[i-][k]+p);
}
}
}
ans=;
for(i=;i<;i++){
ans=max(ans,i/(double)f[n][i]);
}
printf("%.3lf\n",ans);
}
return ;
}
POJ1018 Communication System的更多相关文章
- Communication System(dp)
Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25006 Accepted: 8925 ...
- poj 1018 Communication System
点击打开链接 Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21007 Acc ...
- poj 1018 Communication System 枚举 VS 贪心
Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21631 Accepted: ...
- POJ 1018 Communication System(贪心)
Description We have received an order from Pizoor Communications Inc. for a special communication sy ...
- F - Communication System
We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...
- POJ 1018 Communication System (动态规划)
We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...
- POJ 1018 Communication System(树形DP)
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: 22380 Accepted: ...
- Communication System(动态规划)
个人心得:百度推荐的简单DP题,自己做了下发现真得水,看了题解发现他们的思维真得比我好太多太多, 这是一段漫长的锻炼路呀. 关于这道题,我最开始用DP的思路,找子状态,发现自己根本就不会找DP状态数组 ...
随机推荐
- JZOJ 3521. 道路覆盖
Description ar把一段凹凸不平的路分成了高度不同的N段,并用H[i]表示第i段高度.现在Tar一共有n种泥土可用,它们都能覆盖给定的连续的k个部分. 对于第i种泥土,它的价格为C[i],可 ...
- 转-Spark编程指南
Spark 编程指南 概述 Spark 依赖 初始化 Spark 使用 Shell 弹性分布式数据集 (RDDs) 并行集合 外部 Datasets(数据集) RDD 操作 基础 传递 Functio ...
- C语言函数篇(三)函数参数高级设计
在内存空间中, 1. 单位大小的数据 叫 数值 . 比如 int a; char b; ... 2. 由这些单位数据组合起来的内存, 称作 空间. 比如: 各种数组char/int a[10]; 结构 ...
- C语言进阶——类型转换04
C语言内可以进行类型转换: 强制类型转换 隐式类型转换 强制类型转换的语法: (tpye)value (type)value_name 强制类型转换的结果: 目标类型可以容纳目标值:结果不变 目标值不 ...
- contextmanager 的基本使用
from contextlib import contextmanager 简化 With 语句: class MyResource: def query(self): print ...
- zeppelin之连接mysql
上面的一篇文章,对于zeppelin的使用,只是我们对于数据存储在文件中,每一次对于当我们连接数据库的时候都会有问题,今天刚好 把这个问题解决今天我们刚好来介绍如何使用zeppelin来与数据进行连接 ...
- TouTiao开源项目 分析笔记7 加载数据的过程
1.以新闻页中的段子数据显示为例 1.1.首先执行InitApp==>SplashActivity. 因为在AndroidManifest.xml中定义了一个<intent-filter& ...
- [转]渗透测试tips...零碎的小知识
1.拿到一个待检测的站,你觉得应该先做什么?收集信息whois.网站源IP.旁站.C段网站.服务器系统版本.容器版本.程序版本.数据库类型.二级域名.防火墙.维护者信息另说… 2.mysql的网站注入 ...
- [Jenkins]持续集成环境下fingbug插件的安装使用与配置
参考:https://wiki.jenkins.io/display/JENKINS/FindBugs+Plugin 突然,天降杂事.我是想安安静静的做个美丽的测试...但是事与愿违,项目经理叫我帮忙 ...
- jsUnpacker
EVAL function executeEval(){ let evalCodeElt = document.getElementById("eval_code"); let e ...