Problem F. Judging Time Prediction

题目连接:

http://www.codeforces.com/gym/100253

Description

It is not easy to predict. Do you know that the modern weather prediction is marginally better than to
use the previous day weather as a prediction for the next day?
This problem is about judging a submission on a programming contest like ACM-ICPC. Suppose there is
a single submission for the problem containing n tests. Based on the previous statistics for each test we
know ti the expected time to judge on it and pi the probability of a submission to pass the test.
There are m judging machines in the system. They are completely independent and are used to judge a
submission on multiple tests at the same time. They work as follows. Each time a judging machine has
no task (has just started or nished processing the previous job), it chooses the unprocessed test with the
smallest number and judges submission on the chosen test. If it was judged on the i-th test, then after
time ti the verdict will be known. As it was written above, the probability that a submission passes the
test is pi
.
Let's assume that the judging process starts at the same moment when all the judging machines start. So
at this moment the rst min(m, n) tests start on the judging machines.
You know that on ACM-ICPC contests it is not necessary to judge a submission on all tests. The judging
process will be aborted at the rst moment when two conditions are met at the same time:
• the solution was judged on some test (say, x) and didn't pass it,
• the solution was judged on all the tests 1, 2, . . . , x − 1 and passed all of them.
Naturally, if all the tests are judged and passed the judging process ends too.
Write a program to print the expected time to judge a submission. It means that you are to nd the
mathematical expectation of the judging time according to the specied model.

Input

The rst line of the input contains two integer numbers n and m (1 ≤ n ≤ 3 · 105
, 1 ≤ m ≤ 3 · 105
) the
number of tests and judging machines. The following n lines contain pairs of integers ti and real numbers
pi (1 ≤ ti ≤ 100, 0 < pi < 1), where ti
is the time required to judge the i-th test and pi
is the probability
to pass the i-th test. The values pi are given with no more than 4 digits after the decimal point.

Output

Print the only real number e the expected time to judge the submission. Print it with at least 4 digits
after the decimal point.

Sample Input

2 1
1 0.5
2 0.5

Sample Output

2.0000000000

Hint

题意

有n组test,m个测评姬。

每个空闲的测评姬,会找到当前序号最小,没有测评姬测的测试点进行测试。

其中满足:

1.x测试点wa了

2.前面所有的测试点都测完了。

这个测试就会结束。

现在告诉你每个测评点需要的时间,以及通过的概率,问你期望测试时间。

题解:

拿一个优先队列,测出究竟是哪个测评姬测试这个测试点,以及这个测试点结束的时间。

那么对于第i个测评点的贡献,就是前缀最大值乘上这个测试点挂掉的概率。

代码

#include <bits/stdc++.h>
#define rep(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define drep(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define pb push_back
#define mp make_pair
#define sf scanf
#define pf printf
#define two(x) (1<<(x))
#define clr(x,y) memset((x),(y),sizeof((x)))
#define dbg(x) cout << #x << "=" << x << endl;
const int mod = 1e9 + 7;
int mul(int x,int y){return 1LL*x*y%mod;}
int qpow(int x , int y){int res=1;while(y){if(y&1) res=mul(res,x) ; y>>=1 ; x=mul(x,x);} return res;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 3e5 + 500;
int N , K , t[maxn] ;
long long CompleteTime[maxn];
double prefixp[maxn];
double p[maxn];
double prob = 1.;
struct data{long long x ;int index;friend bool operator < ( const data & a , const data & b ){ return a.x > b.x; }data( long long x , int index ) : x(x) , index( index ) {}
};priority_queue < data > Q;int main(int argc,char *argv[]){//freopen("in.txt" , "r" , stdin );N = read() , K = read();prefixp[0] = 1;for(int i = 1 ; i <= N ; ++ i){scanf("%d%lf" , t + i , p + i );prefixp[i] = prefixp[ i - 1 ] * p[i];}for(int i = 1 ; i <= min( N , K ) ; ++ i){Q.push( data( t[i] , i ) );}int ptr = min( N , K ) ;double ans = 0;while( !Q.empty() ){data st = Q.top() ; Q.pop();CompleteTime[st.index] = st.x;++ ptr;if( ptr <= N ) Q.push( data( st.x + t[ptr] , ptr ));}long long s = 0;for(int i = 1 ; i <= N ; ++ i){s = max( s , CompleteTime[i] );ans += s * prefixp[i - 1] * ( 1. - p[i] ) ;}ans += s * prefixp[N];pf("%.10lf\n" , ans);return 0;
}

转载于:https://www.cnblogs.com/qscqesze/p/5775290.html

2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem F. Judging Time Prediction 优先队列...相关推荐

  1. Codeforces 1070A Find a Number(BFS) 2018-2019 ICPC, NEERC, Southern Subregional Contest Problem A

    Description You are given two positive integers ddd and sss. Find minimal positive integer nnn which ...

  2. 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing

    [链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...

  3. [CodeForces1070C]Cloud Computing(2018-2019 ICPC, NEERC, Southern Subregional Contest )

    传送门:戳我 在cf上做的镜像赛,结果不是很妙啊.. 这题是用时最长但并没有在比赛内写出来(事实上在赛后还话了大概五小时调试才找出错误) 首先不难发现我们需要一棵线段树,(其实一开始我考虑的是主席树) ...

  4. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem I. Plugs and Sockets 费用流

    Problem I. Plugs and Sockets 题目连接: http://www.codeforces.com/gym/100253 Description The Berland Regi ...

  5. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem D. Grumpy Cat 交互题

    Problem D. Grumpy Cat 题目连接: http://www.codeforces.com/gym/100253 Description This problem is a littl ...

  6. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem C. Equivalent Cards 计算几何

    Problem C. Equivalent Cards 题目连接: http://www.codeforces.com/gym/100253 Description Jane is playing a ...

  7. 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest

    A. Automatic Door 对于规律的点可以推公式计算,对于噪点则暴力计算,时间复杂度$O(m\log m)$. #include<stdio.h> #include<ios ...

  8. 2014 ACM/ICPC Asia Regional Guangzhou Online C题Wang Xifeng's Little Plot(dfs)

    Wang Xifeng's Little Plot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  9. 2014 ACM/ICPC 北京赛区网络赛解题报告汇总

    首页 算法竞赛» 信息聚合 ONLINE JUDGE 书刊杂志 BLOG» 新闻故事» 招聘信息» 投稿须知 2014 ACM/ICPC 北京赛区网络赛解题报告汇总 九月 21st, 2014 | P ...

  10. 2016 ACM / ICPC Asia dalian Regional Contest 题解(11 / 11)【每日亿题2021 / 2 / 17】

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A .(2017 ACM ICPC dalian H)To begin or not to be ...

最新文章

  1. Linux下搭建高效的SVN
  2. 阿里云oss云存储图片上传在wangEditor富文本编辑器上的集成
  3. Request.ServerVariables完整参考
  4. TechEd China 2009 课程幻灯片和代码下载 - MBL311 SQL Server Compact 终极性能调校
  5. 快速学习Android开发知识点总结(磨砺营马剑威Android)
  6. flask与js交互的示例代码_dapr实战(1):dapr locally环境的搭建和部署官方的Hello world示例...
  7. 【阿里妈妈数据科学系列】第三篇:离线抽样框架下的AB Test
  8. 2020年,中国AI创业公司将走向何方
  9. elasticsearch-5.6.12 单点安装包括 HEAD插件安装
  10. python中什么是数据驱动_携程大牛谈自动化测试里的数据驱动和关键字驱动思路的理解...
  11. Illustrator中文版教程,如何在 Illustrator 中使用自由变换工具?
  12. 最新csdn有奖任务答案
  13. 发票查询方法怎么查?查验电子发票真伪平台
  14. java图片式验证码的实现(引入hutool工具类和自己编写工具类两种方法)
  15. JAVA后端生成树算法,从指定的叶子节点到树根生成树,从树根到所有叶子结点
  16. 基于Java+Springmvc+vue+element实现高校心理健康系统详细设计和实现
  17. 中国医科大学22春《计算机基础与应用 》在线作业【标准答案】
  18. Linux上连接sybase数据库
  19. Vcenter Server 7 分配许可证
  20. srm安全擦除Linux敏感文件,你受得了吗?-尚文网络xUP楠哥

热门文章

  1. html中自动换行标记[转]
  2. Android版的股票行情K线图开发
  3. SQL SERVER2000安装挂起问题
  4. 火车票软件哪个好用_抢火车票软件哪个好 2019哪个软件抢火车票成功率高
  5. Zynga的数据分析
  6. php cdr,cdr文件用什么打开
  7. 另眼看待 qq 和 360. 资本运作
  8. 吃透Kafka六:topic 创建过程
  9. uni-app 将app运行在夜神安卓模拟器
  10. javascript飞机大战-----007爆炸效果