Codeforces Round 331 (Div. 2)
D
Wilbur and Trees
Codeforces
2300
原题
← CE →
翻译中…

Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.

翻译中…

There are $*n*$ trees located at various positions on a line. Tree $*i*$ is located at position $*x*_{*i*}$. All the given positions of the trees are distinct.

翻译中…

The trees are equal, i.e. each tree has height $*h*$. Due to the wind, when a tree is cut down, it either falls left with probability $*p*$, or falls right with probability $1 - *p*$. If a tree hits another tree while falling, that tree will fall in the same direction as the tree that hit it. A tree can hit another tree only if the distance between them is strictly less than $*h*$.

翻译中…

For example, imagine there are $4$ trees located at positions $1$, $3$, $5$ and $8$, while $*h* = 3$ and the tree at position $1$ falls right. It hits the tree at position $3$ and it starts to fall too. In it's turn it hits the tree at position $5$ and it also starts to fall. The distance between $8$ and $5$ is exactly $3$, so the tree at position $8$ will not fall.

翻译中…

As long as there are still trees standing, Wilbur will select either the leftmost standing tree with probability $0.5$ or the rightmost standing tree with probability $0.5$. Selected tree is then cut down. If there is only one tree remaining, Wilbur always selects it. As the ground is covered with grass, Wilbur wants to know the expected total length of the ground covered with fallen trees after he cuts them all down because he is concerned about his grass-eating cow friends. Please help Wilbur.

翻译中…

Input

翻译中…

The first line of the input contains two integers, $*n*$ $(1 ≤ *n* ≤ 2000)$ and $*h*$ $(1 ≤ *h* ≤ 10^{8})$ and a real number $*p*$ ($0 ≤ *p* ≤ 1$), given with no more than six decimal places.

翻译中…

The second line of the input contains $*n*$ integers, $*x*_{1}, *x*_{2}, ..., *x*_{*n*}$ $( - 10^{8} ≤ *x*_{*i*} ≤ 10^{8})$ in no particular order.

翻译中…

Output

翻译中…

Print a single real number — the expected total length of the ground covered by trees when they have all fallen down. Your answer will be considered correct if its absolute or relative error does not exceed $10^{ - 6}$.

翻译中…

Namely: let's assume that your answer is $*a*$, and the answer of the jury is $*b*$. The checker program will consider your answer correct, if image.

翻译中…

Note

翻译中…

Consider the first example, we have 2 trees with height 2.

翻译中…

image

翻译中…

There are 3 scenarios:

翻译中…
  1. Both trees falls left. This can either happen with the right tree falling left first, which has image probability (also knocking down the left tree), or the left tree can fall left and then the right tree can fall left, which has image probability. Total probability is image.
翻译中…
  1. Both trees fall right. This is analogous to (1), so the probability of this happening is image.
翻译中…
  1. The left tree fall left and the right tree falls right. This is the only remaining scenario so it must have image probability.
翻译中…

Cases 1 and 2 lead to a total of 3 units of ground covered, while case 3 leads to a total of 4 units of ground covered. Thus, the expected value is image.

翻译中…

样例

Input #1
2 2 0.500000
1 2
Output #1
3.250000000
InputCopy OutputCopy
Input #2
4 3 0.4
4 3 1 2
Output #2
6.631200000
InputCopy OutputCopy
题目信息
题号
596D
时间限制
2 s
内存限制
256 MB
标签
动态规划
数学
概率论
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。