問題一覧 > 通常問題

No.1590 Random Shopping

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-6}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : e869120 / テスター : hirakich1000000007
お気に入りにしたユーザー ProblemId : 6695 / 自分の提出
問題文最終更新日: 2021-07-08 21:59:39
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 303 (順位表) の他の問題:

Problem Statement

At the yuki shop, items will be sold over the next $N$ days. On the morning of day $i$ $(1 \leq i \leq N)$, a new item priced at $A_i$ yen is added, and it remains in the shop until it is sold.

From now on, $1$ customer is scheduled to come per $1$ day. The wealth of the customer who comes on the evening of day $i$ $(1 \leq i \leq N)$ is $R_i$. Every customer buys "the cheapest item among those currently remaining" with probability $50\%$, and leaves without buying an item with probability $50\%$.

The satisfaction of the shopping is the sum, over all customers, of "wealth $\times$ price of the purchased item". A customer who leaves without buying an item has satisfaction $0$. Find the expected value of the satisfaction.

Input

$N$
$A_1$ $A_2$ $\cdots$ $A_N$
$R_1$ $R_2$ $\cdots$ $R_N$

Output

Output the expected value of the satisfaction. Your answer is considered correct if the absolute or relative error is at most $10^{-6}$.

Constraints

  • $1 \leq N \leq 500$
  • $1 \leq A_i \leq 1000$
  • $1 \leq R_i \leq 1000$
  • All input values are integers

Sample

Sample 1
Input
2
4 6
9 3
Output
25.5

In this sample, the following $4$ events occur with equal probability:

  • No one buys an item: the satisfaction is $0$
  • The customer who comes on day $1$ buys an item: the satisfaction is $9 \times 4 = 36$
  • The customer who comes on day $2$ buys an item: the satisfaction is $3 \times 4 = 12$
  • The customers who come on days $1, 2$ buy items: the satisfaction is $9 \times 4 + 3 \times 6 = 54$
Therefore, the expected value of the satisfaction is $(0 + 36 + 12 + 54) \div 4 = 25.5$.

Sample 2
Input
4
1 1 1 1
1 1 1 1
Output
2.0
Sample 3
Input
8
3 1 4 1 5 9 2 6
5 3 5 8 9 7 9 3
Output
50.75

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。