Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 2048 MB Total points: 100 Difficulty: [show] Hackable ✓
Statistics

杰西(Jayce)正在進行一場《海克斯大亂鬥》(ARAM: Mayhem)。他來到了強化符文選擇階段,正在尋找能夠帶領隊伍走向勝利的完美強化符文。具體而言,他正苦苦追尋名為「急中生智」(Slow and Steady)的金色強化符文。

problem_16335_d8c98da6fac715f321d5428116fbdb05.png
卡牌選擇的遊戲介面。糟糕,看來杰西在稜彩池裡是不可能找到「急中生智」了……

目前,遊戲介面向杰西展示了 $k$ 張強化符文卡。雖然每張卡都有不同的效果,但對杰西而言,當前可見的第 $i$ 張卡價值 $a_i$ 點戰力值。牌庫中還有一個包含 $n$ 張其他強化符文卡的隱藏卡池。已知這些卡牌的戰力值構成多重集 $\{b_1, b_2, \dots, b_n\}$,但它們在牌庫中的順序是以均勻隨機的方式洗牌的。

杰西可以對這 $k$ 個卡槽分別重骰至多一次。流程如下:

  • 在 $k$ 張卡的下方各有一個獨立的重骰按鈕(如遊戲介面所示)。
  • 杰西可以選擇一個尚未重骰過的卡槽,捨棄目前的卡牌,並從牌庫頂端抽取一張卡來取代它。
  • 杰西在每次重骰後會立即看到結果,然後才決定下一步行動:要繼續重骰另一個可用的卡槽,或是停止。

在流程結束時,杰西會從目前螢幕上可見的 $k$ 張卡中挑選一張。

杰西會採取最佳策略,以最大化他最終所選卡牌的期望價值。請計算此最大期望戰力值。

輸入格式

第一行包含兩個整數 $k$ 與 $n$($1 \le k \le n \le 10^5$),分別代表可見卡槽的數量與牌庫中卡牌的數量。

第二行包含 $k$ 個整數 $a_1, a_2, \dots, a_k$($-10^5 \le a_i \le 10^5$),代表初始可見卡牌的戰力值。

第三行包含 $n$ 個整數 $b_1, b_2, \dots, b_n$($-10^5 \le b_i \le 10^5$),代表牌庫中卡牌的戰力值。

輸出格式

輸出一個十進位實數,代表卡牌的最大期望價值。

若你的輸出與裁判答案的絕對誤差或相對誤差不超過 $10^{-4}$,則視為正確。形式化地說,假設你的輸出為 $a$,裁判的答案為 $b$,若且唯若 $\frac{|a - b|}{\max(1, |b|)} \le 10^{-4}$ 時,你的輸出會被接受。

範例

輸入 1

1 2
10
1 100

輸出 1

50.5

輸入 2

3 5
3 4 7
1 2 3 5 8

輸出 2

7.4

輸入 3

2 4
-1 -2
-3 -4 -5 -6

輸出 3

-1

輸入 4

5 14
1 3 5 7 9
-1 -1 0 0 2 2 4 4 6 6 8 8 10 10

輸出 4

9.505494505

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.