分析:

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

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

因此先对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. 多实例:MySQL系列之二

    MySQL的多实例配置 ​ 在一台物理机中需要多个测试环境,那么就需要用到了搭建数据库的多个实例,多个实例的意思就是运行多份程序,实例与实例之间没有影响.要注意监听的端口需要不同. 环境:CentOS ...

  2. js千分位处理

    一.去掉千分位 function removeThousands(num) { var x = num.split(','); return parseFloat(x.join("" ...

  3. PHP学习 文件操作函数的应用--简单网络留言模板

    <?php /** 网络留言板模式 主要运用到的函数有 fopen fclose flock fwrite fread explode list */ ?> <meta http-e ...

  4. java动态线程池LinkedBlockingQueue和SynchronousQueue比较

    import java.util.concurrent.Callable; public class MyCallable implements Callable<String> { pr ...

  5. py---------网络编程

    一.软件开发架构 我们了解的涉及到两个程序之间通讯的应用大致可以分为两种: 第一种是应用类:qq.微信.网盘.优酷这一类是属于需要安装的桌面应用 第二种是web类:比如百度.知乎.博客园等使用浏览器访 ...

  6. java编程如何实现从本地里读取文件1,写入到本地另一个文件2里(多种场景)

    不多说,直接上干货! 有时候,我们需要用到这样的一个场景. ReadLocalFile1WriteLocalFile2.java (以下是相当于复制,读取文件1里的全部内容,并写入到文件2里) pac ...

  7. Sqoop概述

    sqoop Sqoop 是传统数据库与 Hadoop 之间数据同步的工具,它是 Hadoop 发展到一定程度的必然产物,它主要解决的是传统数据库和Hadoop之间数据的迁移问题.这节课我们将详细介绍 ...

  8. JSP标签和JSTL标签注意点

    1.转发和重定向问题 当前项目:/Test 转发路径:"/"根目录表示当前项目"/Test","/login.jsp"就是"/Te ...

  9. PHP 中获取文件名及路径

    1. basename("/mnt/img/image01.jpg")函数:得到文件名;输出结果为:image01.jpg. 使用 basename($uriString) 我们可 ...

  10. android 开发DatePickerDialog/TimePickerDialog对话框的实现

    AndroidAPI提供了Dialog对话框控件,DatePickerDialog/TimePickerDialog均是AlertDialog的子类,通过DatePickerDialog/TimePi ...