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> ...
随机推荐
- Android开发——Context类的各种细节问题
0. 前言 Context相信所有的Android开发人员基本上每天都在接触,因为它太常见了.但实际上Context有太多小的细节并不被大家所关注,那么今天我们就来学习一下那些你所不知道的细节. ...
- 成都Uber优步司机奖励政策(1月12日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 说说CakePHP的关联模型之一 基本关联
一个无论多么复杂的程序,拆开看无非是三种逻辑结构的组合:顺序结构.条件结构和循环结构. 类似的,数据库中表与表的之间的关联无外乎四种:一对一.一对多.多对一和多对多. CakePHP的模型层中定义了四 ...
- 海思NB-IOT的SDK看门狗的使用
1. 看门狗需要喂狗,如果自己写的任务一直运行,那么空闲任务无法运行会导致看门狗复位,来看下看门狗的机制,首先系统启动的时候创建了空闲任务 在这个函数里面void vTaskStartSchedule ...
- python generator
def reverse(data): for index in range(len(data)-1, -1, -1): yield data[index] for char in reverse('g ...
- 第四十篇 Python之设计模式总结-简单工厂、工厂方法、抽象工厂、单例模式
一. 简单工厂 简单工厂模式(Simple Factory Pattern):是通过专门定义一个类来负责创建其他类的实例,被创建的实例通常都具有共同的父类. 简单工厂的用处不大,主要就是一个if... ...
- UE4蓝图小记
http://www.element3ds.com/forum.php?mod=viewthread&tid=76930&page=1&authorid=104414 http ...
- Django学习总结之模板templates
- django模板: templates - 模板分为两个过程: 1, 加载 : loader.get_template('xxx.html') 返回值是一个template对象 2, 渲染 : t ...
- sql server存储特殊字符解决办法
好久没来院子了,最近在学java了,再加上项目比较紧,最近都没怎么上,其实这几天在项目中学到不少东西,都能写下来,但是久而久之就忘了,还是得养成及时总结的好习惯啊,还有有时间一定要把那个小项目整理下来 ...
- 57[LeetCode] Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...