poj 1018 Communication System
2010-05-14 11:21
309 查看
http://blog.csdn.net/woshixingaaa/archive/2010/05/14/5590207.aspx
题意:有一些设备,不同制造商的带宽和价格是不一样的,带宽是每种设备所选制造商的最小带宽,价格是各个设备所选制造商的价格之和
思路:枚举每一种带宽作为最小带宽,再枚举每个设备的价格,在设备的带宽不小于最小带宽的情况下使每种设备的价格尽量小,不断调整每种设备的价格.
代码(110MS, 324K)
#include <iostream> #include <set> using namespace std; struct Device{ int mi; int band[100]; float price[100]; }; int main(){ int t, n, j, i; float ans, minband; cin>>t; set<int> Band; set<int>::iterator q; while(t--){ cin>>n; ans = 0; Device *p = new Device ; for(i = 0; i < n; i++){ cin>>p[i].mi; for(j = 0; j < p[i].mi; j++){ cin>>p[i].band[j]>>p[i].price[j]; Band.insert(p[i].band[j]); } } for(q = Band.begin(); q != Band.end(); q++){ minband = *q; int total = 0; for(i = 0; i < n; i++){ double min = 10000000; for(j = 0; j < p[i].mi; j++) if(p[i].band[j] >= minband && p[i].price[j] < min) min = p[i].price[j]; total += min; } if(ans < minband / total) ans = minband / total; } printf("%.3f/n", ans); delete p; } return 0; }
相关文章推荐
- poj 1018 Communication System(枚举+贪心)
- POJ 1018(二分)
- poj 1018
- POJ 1018 Communication System(DP)
- POJ 1018 Communication System
- POJ 1018 Communication System(贪心+优化)
- POJ 1018 Communication System
- poj1018
- poj 1018
- poj 1018 Communication System
- POJ1018-Communication System
- POJ 1018 Communication System
- POJ 1018 Communication System
- POJ 1018 - Communication System (枚举)
- POJ 1423 &&hdu 1018 Big Number【数学】
- poj 1018 dp
- POJ 1018
- POJ 1018 Communication System(动态规划)
- poj-1018随写
- POJ 1018