Playlist codeforces 268E
来源:互联网 发布:怎样开个淘宝网店 编辑:程序博客网 时间:2024/05/01 08:24
1.Consider any two songs which are at positions i and j (i < j) in the playlist. If Manao liked song i and disliked song j, then song i will be listened to again. Therefore, with probability p[i]*(1-p[j])
the process length will increase by L[i]
. The sum of L[i]*p[i]*(1-p[j])
over all pairs (plus the length of all songs since Manao listens to them at least once) is the expected length for the fixed sequence.
So we have that if there are two songs (l1, p1) and (l2, p2), the first one should be placed earlier in the playlist ifl1*p1*(1-p2)>l2*p2*(1-p1)
and later otherwise.
2.Suppose we have fixed j and are counting the contribution of song j towards the answer if Manao dislikes it. This value is(l1*p1 + l2*p2 + ... + l[j-1]*p[j-1])
. For j+1, the corresponding value will be(l1*p1+...+l[j-1]*p[j-1]+l[j]*p[j])
. It turns out that these values differ in only a single summand, so we can compute each of them in O(1)
- Playlist codeforces 268E
- Codeforces 268E Playlist
- codeforces 268E Playlist(数学期望)
- Codeforces Round #164 (Div. 2) E. Playlist【概率,期望】
- Codeforces-268b E Buttons
- codeforces 163E e-Government
- 【Codeforces 163E】E-Government
- Codeforces 78E Evacuation
- 【dp】codeforces 83E
- Codeforces 124 E
- Codeforces 231E
- Codeforces 231E - Cactus
- Codeforces #163 Div2 E
- codeForces 35E
- Codeforces 35E
- Codeforces 148E(Porcelain)
- codeforces round#177 E
- codeforces 203E Transportation
- oracle体系基础部分之跟踪文件
- 方舟子讽老罗捞粪获得灵感
- shell中if判断的参数
- git提交方式
- IT的成功人士学习之道
- Playlist codeforces 268E
- Playfair密码变种加密
- poj 2299 求逆序对
- 自己动手编写一个VS插件(一)
- iOS中永久保存用户数据的两个地方
- 情感词生成
- free与delete的区别
- 蝴蝶效应---。。。
- C语言---变长参数列表---变长参数的使用