Communication System
Time Limit:1000MS |
|
Memory Limit:10000K |
Total Submissions:21187 |
|
Accepted:7524 |
Description
We have received an order from Pizoor Communications Inc. for a special communication system. The system consists of several devices. For each device, we are free to choose from several manufacturers. Same devices from two manufacturers differ in their maximum
bandwidths and prices.
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
The 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
Your 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#include<iostream>
using namespace std;
int v[101][101][3];
int l[101];
int minB(){
int min=10000,index=0;
for(int i=1;i<101;i++){
for(int j=1;j<101;j++){
if(v[i][j][2]&&v[i][j][0]<min){
min=v[i][j][0];
}
}
}
return min;
}
int getMax(int n[][3],int l,int P){
int maxJ=1;
double r=0;
for(int i=1;i<=l;i++){
int B1;
if(n[i][0]>minB())
B1=minB();
else
B1=n[i][0];
int P1=P+n[i][1];
if(B1*1.0/P1>r){
r=B1*1.0/P1;
maxJ=i;
}
}
return maxJ;
}
int main(){
int m,B=0,P=0;
cin>>m;
for(int i=1;i<101;i++)
for(int j=1;j<101;j++)
for(int k=0;k<=2;k++)
v[i][j][k]=0;
for(int i=1;i<=m;i++){
cin>>l[i];
for(int j=1;j<=l[i];j++)
cin>>v[i][j][0]>>v[i][j][1];
}
for(int i=1;i<=m;i++){
int t=getMax(v[i],l[i],P);
P+=v[i][t][1];
v[i][t][2]=1;
}
cout<<minB()*1.0/P<<endl;
system("pause");
}
分享到:
相关推荐
北大POJ1018-Communication System 解题报告+AC代码
Communication System Design Using DSP Algorithms with Lab Expers for the TMS320C6713 DSK - S. Tretter Springer, 2008
10 MONTE CARLO SIMULATION OF COMMUNICATION SYSTEMS 11 METHODOLOGY FOR SIMULATING A WIRELESS SYSTEM Part III Advanced Models and Simulation Techniques 12 MODELING AND SIMULATION OF NONLINEARITIES 13 ...
图形学之父的博士论文:Sutherland:Sketchpad A man-machine graphical communication system.pdf
Audio signal processing for next-generation multimedia communication system, MIMO 理论在音频领域的最新应用,相当前卫哦
《Principles of Communication System Simulation with Wireless Aplications》书中附带的源代码,虽然可以在网上找到,但是链接不是那么好找。费了一番功夫,找出来给大家共享。 The hands-on, example-rich ...
国外教材,通信系统的一些基本知识,适合初学者学习
国外教材,牛津大学出版社~学通信的都要用
Digital communication systems using SystemVue / Dennis Silage. p. cm. Includes index. ISBN 1-58450-850-7 (alk. paper) 1. Digital communications. I. Title. TK5103.7.S49 2005 621.382--dc22 2005031785
pricinples of communication system simulation with wireless aplications
solution for communication system
大牛写的多速率信号处理书,面向通信领域,内容详实,深入浅出。
Communication System by Simon Haykin 5E Solutions Manual
Multirate signal processing for communication system harris
simulation of communication system, second edition 中文翻译版
现代通信系统书籍,原著,英文版pdf,不要需要几个积分哦
论文阅读笔记 Xie_Deep Learning Enabled Semantic Communication System 共计9页,详细手写
Multirate signal processing for communication system harris
( DSP embedded wireless communication system fine )。很好DSP书籍,非常有用