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.