#include<iostream>
#define MAXN 105
#define inf 10000000
#include<vector>
#include<iomanip>
#include<algorithm> using namespace std; struct node
{
double b;
double p;
}; vector<double> coll; node _m[MAXN][MAXN];
int size[MAXN];
int n;
void sort_f();
int main()
{
//freopen("acm.acm","r",stdin);
int i;
int j;
int k;
double min;
int test;
double sum;
double max;
double temp;
bool boo;
cin>>test;
while(test --)
{
boo = false;
sum = ;
max = -;
cin>>n;
for(i = ; i < n; ++ i)
{
cin>>size[i];
for(j = ; j < size[i]; ++ j)
{
cin>>_m[i][j].b>>_m[i][j].p;
coll.push_back(_m[i][j].b);
}
}
sort(coll.begin(),coll.end());
sort_f();
for(k = ; k < coll.size(); ++ k)
{
if(k > && coll[k] == coll[k-])
continue;
sum = ;
for(i = ; i < n; ++ i)
{
min = inf;
boo = false;
for(j = ; j < size[i]; ++ j)
{
if(_m[i][j].b >= coll[k])
{
if(_m[i][j].p < min)
min = _m[i][j].p;
boo = true;
}
else
break;
}
if(boo == false)
{
sum = ;
break;
}
sum += min;
}
if(!boo)
break;
if( (temp = double(coll[k]/sum)) > max)
{
max = temp;
//cout<<max<<endl
} }
cout<<setiosflags(ios::fixed)<<setprecision()<<max<<endl;
coll.clear();
}
} void sort_f()
{
int i;
int j;
int k;
for(i = ; i < n; ++ i)
{
for(j = ; j < size[i]; ++ j)
{
for(k = j+; k < size[i]; ++ k)
{
if(_m[i][k].b > _m[i][j].b)
{
iter_swap(&_m[i][k].b,&_m[i][j].b);
iter_swap(&_m[i][k].p,&_m[i][j].p);
}
}
}
}
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1018的更多相关文章

  1. POJ 1018 Communication System(树形DP)

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

  2. POJ 1018 【枚举+剪枝】.cpp

    题意: 给出n个工厂的产品参数带宽b和价格p,在这n个工厂里分别选1件产品共n件,使B/P最小,其中B表示n件产品中最小的b值,P表示n件产品p值的和. 输入 iCase n 表示iCase个样例n个 ...

  3. POJ 1018 Communication System(DP)

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

  4. POJ 1018 Communication System 贪心+枚举

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

  5. 【贪心】Communication System POJ 1018

    题目链接:http://poj.org/problem?id=1018 题目大意:有n种通讯设备,每种有mi个制造商,bi.pi分别是带宽和价格.在每种设备中选一个制造商让最小带宽B与总价格P的比值B ...

  6. poj 1018 Communication System

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

  7. poj 1018 Communication System_贪心

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

  8. poj 1018 Communication System 枚举 VS 贪心

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

  9. 2017ecjtu-summer training #11 POJ 1018

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

  10. POJ 1018 Communication System(贪心)

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

随机推荐

  1. hdu-1251(string+map)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 思路:重点是用gets输入,而且用a[20],不能直接输入string类型的. #include ...

  2. 25. Green Living 绿色生活

    25. Green Living 绿色生活 ①We all know that humans are damaging the environment,but what can we do about ...

  3. 使用vbs给PPT(包括公式)去背景

    在 视图—>宏 内新建宏 '终极版 Sub ReColor() Dim sld As Slide Dim sh As Shape For Each sld In ActivePresentati ...

  4. PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏

    1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  5. hdu 1266 Reverse Number

    题目 一道水题,但是超时了几次(Time Limit Exceeded) 题中说:then n 32-bit integers follow.私以为可以用int来做,结果就一直超时,博客之,发现全是用 ...

  6. Should Assertion Library

    Should Assertion Library,通常在测试时用到,可以与nunit 结合使用. 已经从codeplex 迁移到 github.网址如下 https://github.com/eric ...

  7. delphi字符串固定长度换行

    var   str,capstr:string;   i,j:integer;   .................... j:=500;   //这个地方可能要根据你显示的宽度来换算对应的字符长度 ...

  8. WinRT 中后台任务类的声明

    要实现后台任务,需要实现IBackgroundTask接口 public sealed class SimpleTask : IBackgroundTask { public void Run(IBa ...

  9. CSS2.1SPEC:视觉格式化模型之width属性详解(下)

    本文承接CSS2.1SPEC:视觉格式化模型之width属性详解(上),继续分析CSS视觉格式化模型中width以及相关值的计算问题: 注:与上节不同,本节的demo中由于出现了float,absol ...

  10. JQuery Mobile - 修改复选框的选中状态无效解决办法!

    今晚,在编写JQuery Mobile程序时候,需要在代码里面控制复选框的选中状态,很简单的代码啊,很快完成了!等测试程序时候傻眼了,页面无论如何也不按照我写的代码显示出来!问题出在哪里呢?是我写的控 ...