P27401 [AtCoder] Indifferent
NOI
题目描述

Problem Description

There are $2N$ pots. Among them, the market price of the $i$-th pot $(1 \leq i \leq 2N)$ is $p_i$ yen.

You and Lunlun the Dachshund will take turns picking one pot each. You start first, and this continues until all pots are taken by either you or Lunlun. Lunlun does not know the market price of the pots, so each time, he randomly selects one from the remaining pots with equal probability. You know Lunlun's behavior and the market prices of the pots.

Your goal is to maximize the expected value of $S$, the total market price of the pots you take. Find the expected value of $S$ when using the optimal strategy.

Input Format

The input is given from the standard input in the following format:

$N$ $p_1$ $p_2$ $...$ $p_{2N}$

Output Format

Output the expected value of $S$ when using the strategy that maximizes the expected value of $S$. The output will be considered correct if the absolute or relative error from the judge's output is within $10^{-9}$.

Sample Input and Output

Sample Input #1

1
150000
108

Sample Output #1

150000.0

Sample Input #2

2
50000
50000
100000
100000

Sample Output #2

183333.3333333333

Notes/Hints

Constraints

  • $1 \leq N \leq 10^5$
  • $1 \leq p_i \leq 2 \times 10^5$
  • All input values are integers.

Sample Explanation 1

Naturally, you should choose the pot worth 150,000 yen.

Sample Explanation 2

First, you should take one of the pots worth 100,000 yen. The other pot worth 100,000 yen will be yours if Lunlun does not take it next, which has a probability of $2/3$. If Lunlun takes that pot, you will have to settle for a pot worth 50,000 yen. From this, the expected value of $S$ when using the optimal strategy is $2/3 \times (100000 + 100000) + 1/3 \times (100000 + 50000) = 183333.3333...$

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 150000 108
样例输出
150000.0