poj 1018 Communication System(DP)
来源:互联网 发布:闲鱼淘宝介入偏向买家 编辑:程序博客网 时间:2024/05/22 18:22
可能有很多方法吧,用的DP做的,其他的现在暂时不知道怎么用,枚举的是带宽,如果选择了价格来枚举的话,用的内存可能会更大而且一般是会TLE的
代码在这:
#include <iostream>#include <cstdio>using namespace std;int dp[110][1100];int b[110][110];int p[110][110];int t,n;int m[110];int main(){scanf("%d",&t);while(t--){scanf("%d",&n);for(int i=1;i<=n;++i){scanf("%d",&m[i]);for(int j=1;j<=m[i];++j){scanf("%d%d",&b[i][j],&p[i][j]);}for(int j=0;j<1100;++j)dp[i][j]=1e8;}for(int i=1;i<=n;++i){for(int j=1;j<=m[i];++j){if(i==1) dp[1][b[1][j]]=min(dp[1][b[1][j]],p[1][j]);else{for(int k=0;k<1100;++k){if(dp[i-1][k]!=1e8){if(k<=b[i][j]) dp[i][k]=min(dp[i][k],dp[i-1][k]+p[i][j]);else dp[i][b[i][j]]=min(dp[i][b[i][j]],dp[i-1][k]+p[i][j]);}}}}}double res=0;for(int i=0;i<1100;++i){if(dp[n][i]!=1e8){double x=(double)i/dp[n][i];if(x>res) res=x;}}printf("%.3f\n",res);}return 0;}
0 0
- POJ 1018 Communication System (DP)
- POJ 1018 Communication System dp
- POJ 1018:Communication System - DP
- POJ 1018Communication System(DP)
- poj 1018 Communication System(DP)
- poj 1018 Communication System DP思想
- poj - 1018 - Communication System(dp)
- POJ 1018 Communication System(简单DP)
- poj 1018 Communication System-dp+离散化
- poj 1018 Communication System(DP)
- poj 1018 Communication System (dp | 贪心)
- 【POJ 1018】Communication System(dp|贪心)
- poj 1018 Communication System
- POJ 1018 Communication System
- poj 1018 Communication System
- POJ 1018 Communication System
- POJ 1018 Communication System
- POJ 1018 Communication System
- myclipse 项目如何改上下文
- Http请求中Content-Type讲解以及在Spring MVC中的应用
- faster rcnn +cudnn V5
- 数据结构实验:连通分量个数
- UE4材质笔记
- poj 1018 Communication System(DP)
- SpringExt 源码学习
- linux下上传代码到github
- Maven POM中的各种scope的行为总结
- [JavaScript]按天倒计时代码
- HDOJ 1541 Stars(树状数组)
- Emulator Control无法使用解决方法(SDK Tools版本和ADT版本不一致引起)
- Android 音乐播放器
- hdu1097 A hard puzzle