分析:

状态是一些有序的集合,这些集合互不相交,并集为所有区域。显然枚举集合元素是哪些是无法承受的,

写出期望的计算式,会发现,当每个集合的大小确定了以后,概率大的优先访问是最优的。

因此先对u从大到小排序。定义状态f[i][j]表示从j开始往后分i组的最小期望。

转移是枚举划分k,则有f[i][j] = min{f[i-1][k]+(k-j)*(sum_u(j,n))},k>j

边界f[1][j] = (n-j+1)*(u[j])

处理出u的前缀和

复杂度O(w*n^2)

#include<bits/stdc++.h>
using namespace std; const int maxn = 100+;
int u[maxn];
int f[][maxn];
const int INF = 0x3f3f3f3f; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int T; cin>>T;
while(T--){
int n,w; scanf("%d%d",&n,&w);
for(int i = ; i <= n; i++) scanf("%d",u+i);
sort(u+,u++n,greater<int>());
for(int i = ; i <= n; i++) u[i] += u[i-];
for(int j = n; j > ; j--){
f[][j] = (n-j+)*(u[n]-u[j-]);
}
for(int i = ; i <= w; i++){
for(int j = ; j <= n; j++){
f[i][j] = INF;
for(int k = j+; k <= n; k++){
f[i][j] = min(f[i-][k]+(k-j)*(u[n]-u[j-]),f[i][j]);
}
}
}
printf("%.4lf\n", f[w][]/(double)u[n]);
}
return ;
}

UVALive 4731 Cellular Network(贪心,dp)的更多相关文章

  1. UVaLive 4731 Cellular Network (期望DP)

    题意:手机在蜂窝网络中的定位是一个基本问题,假设蜂窝网络已经得知手机处于c1,c2,,,cn这些区域中的一个,最简单的方法是同时在这些区域中寻找手机, 但这样做很浪费带宽,由于蜂窝网络中可以得知手机在 ...

  2. UVA 1456 六 Cellular Network

    Cellular Network Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit S ...

  3. codeforces 702C Cellular Network 2016-10-15 18:19 104人阅读 评论(0) 收藏

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  4. 【BZOJ-3174】拯救小矮人 贪心 + DP

    3174: [Tjoi2013]拯救小矮人 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 686  Solved: 357[Submit][Status ...

  5. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  6. Educational Codeforces Round 15 Cellular Network

    Cellular Network 题意: 给n个城市,m个加油站,要让m个加油站都覆盖n个城市,求最小的加油范围r是多少. 题解: 枚举每个城市,二分查找最近的加油站,每次更新答案即可,注意二分的时候 ...

  7. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. 【暑假】[实用数据结构]UVAlive 3027 Corporative Network

    UVAlive 3027 Corporative Network 题目:   Corporative Network Time Limit: 3000MS   Memory Limit: 30000K ...

  9. cf702C Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. HTML5 为 <input> 增加的属性 ; 为 <form> 增加的如需属性

    HTML5 为 <input> 增加了如下属性: autocomplete autofocus form formaction formenctype formmethod formnov ...

  2. C#多进程并行

    为了并行执行多个任务,可以启动多个进程(并行数). 下面提供两种方法,总任务数10,最大并行数4. 一.方法1 using System; using System.Collections.Gener ...

  3. File类、递归

    File类.递归 1.1File类概述 java.io.File表示文件和目录路径名的抽象类.可以对文件和文件夹进行创建删除.获取.判断.遍历等功能. 1.2路径\文件分割符,相对路径绝度路径 1.2 ...

  4. 洛谷P3078 [USACO13MAR]扑克牌型Poker Hands

    题目描述 Bessie and her friends are playing a unique version of poker involving a deck with \(N\) (\(1 \ ...

  5. 与Webpack最后的战斗

    今天用自己搭的脚手架做react项目,终于还是在图片加载的地方出错了.决定好好地看一次最新的官网.顺带写个完整的教程.

  6. [Leetcode]008.String to Integer (atoi)

    public class Solution { public int myAtoi(String str) { int index = 0, sign = 1, total = 0; //1. 边界条 ...

  7. Flask&&人工智能AI --2

    参考博客: https://www.cnblogs.com/xiao987334176/p/9598606.html 昨日作业讲解 昨天的作业就是,有3个视图函数,分别是/login,/student ...

  8. java日期与时间戳相互转换大全

    转载大神 https://blog.csdn.net/djc777/article/details/50904989/

  9. linux读取yaml文件的某个属性值

    trigger=$(cat test.yaml | grep "trigger" | awk '{print $2}') 该条命令的意思是:读取test.yaml文件中的trigg ...

  10. Hadoop完全分布式环境下,DataNode进程正常启动,但是网页上不显示DataNode节点

    Hadoop完全分布式环境下,上传文件到hdfs上时报错: // :: WARN hdfs.DFSClient: DataStreamer Exception org.apache.hadoop.ip ...