#P16652. [GKS 2018 #E] Board Game

    ID: 19015 远端评测题 10000~30000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2018Special Judge前缀和Google Kick Start

[GKS 2018 #E] Board Game

Problem Description

Bahu is playing a board game with Bala. Each player has 3N3 \cdot N army cards with various strength values. There are 33 battlefields in the game. Each player must distribute their cards among the battlefields, face down, such that each battlefield gets exactly NN of their cards.

When the game begins, all cards will be revealed. For each battlefield, each player sums up the strength values of their NN cards in that battlefield, and then the players compare those totals. If one player has a higher total, that player wins that battlefield. If the totals are the same, Bala wins that battlefield; this is his special advantage.

The overall winner of the game is the player who wins the most battlefields. (Since there are 33 battlefields, it is guaranteed that there will not be an overall tie.)

Bala thinks that his advantage is enough to make him win, so he just randomly shuffles his cards and puts the first NN on the first battlefield, the next NN on the second battlefield, and the last NN on the third battlefield.

Even though Bahu is at a disadvantage, he is still going to try to win! Find the probability that he will win if he distributes his cards optimally. Note that all Bala's cards are faced down so Bahu must choose the distribution of his cards before seeing the distribution of Bala's cards.

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow; each consists of three lines. The first line contains an integer NN, as described above. The second line contains 3N3 \cdot N integers A0,A1,,A3N1A_0, A_1, \dots, A_{3N-1}, representing the strength values of Bahu's cards. The third line consists of 3N3 \cdot N integers B0,B1,,B3N1B_0, B_1, \dots, B_{3N-1}, representing the strength values of Bala's cards.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the probability described above. y will be considered correct if it is within an absolute or relative error of 10610^{-6} of the correct answer.

2
3
2 2 2 2 2 2 2 3 3
2 2 2 2 2 2 2 2 2
3
2 2 2 2 2 2 2 3 3
2 2 2 2 2 2 2 2 3
Case #1: 1.000000000
Case #2: 0.333333333

Hint

In Sample Case #1, Bahu can put cards (22, 22, 22) in first battle field, (22, 22, 33) in second battle field and (22, 22, 33) in third battle field. As all Bala's cards are 22, Bala wins the first battle field and Bahu wins the second and third battle field.

Limits

1T1001 \le T \le 100.

1Ai1061 \le A_i \le 10^6, for all ii.

1Bi1061 \le B_i \le 10^6, for all ii.

Small dataset (Test set 1 - Visible)

N=3N = 3.

Large dataset (Test set 2 - Hidden)

3N53 \le N \le 5.