403755: GYM101257 G 24

Memory Limit:256 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. 24time limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Round 16,777,216 of Codeforce-is has just finished, and all the contestants were able to pass the pretests in problem A.

Maike, the founder of Codeforce-is wants to measure how weak the tests for problem A were, so he became interested in finding the amount of changes that will occur on the contest’s scoreboard after the system tests.

Given the score for problem A, the score of each contestant before the system tests, and the probability of failing the system tests for each contestant’s solution, can you help Maike find the expected number of pairs of contestants that will swap their relative order after the system tests? That is, the number of pairs of contestants i, j such that the scorei  >  scorej before the system tests, but scorei  <  scorej after the system tests.

Input

The first line of input consists of two integers, N (2 ≤ N ≤ 105), and SA (1 ≤ SA ≤ 105), the number of contestants in the round, and the score the contestants achieved for passing the pretests of problem A.

The second line contains N space-separated integers, the Kth integer is TK (SA ≤ TK ≤ 105) which represents the total score in the contest for the Kth contestant before the system tests, Ti  ≥  Ti + 1 for (1 ≤ i < N).

The third and final line contains N space-separated numbers, the Kth number is PK (0.01 ≤ PK ≤ 1.00) which represents the probability that the Kth contestant's solution will fail the system tests. Numbers are given with exactly two digits after the decimal point.

Output

On a single line, output the expected number of pairs of contestants that will swap their relative order after the system tests are over.

ExamplesInput
2 10
25 20
0.50 0.50
Output
0.250000000
Input
4 10
25 20 15 15
1.00 0.50 1.00 0.50
Output
0.750000000

加入题单

上一题 下一题 算法标签: