Three Kinds of Dice

시간 제한1초메모리 제한1024 MB

요약
한 주사위가 다른 주사위를 이기는 두 주사위가 주어질 때, 승자에게 지지 않으면서 패자에게 얻을 수 있는 최소 점수와, 패자에게 지지 않으면서 승자에게 얻을 수 있는 최대 점수를 구한다.
난이도

어려움10점 중 8점

유형
수학, 정렬, 누적 합, 이분 탐색
정답자
아직 제출이 없습니다

문제

See how they roll! According to a famous story, Warren Buffett once challenged Bill Gates to a simple game of dice. He had three dice; the first player could examine them and choose one of the three. The second player would then choose one of the remaining dice, and both players would roll their dice against each other, aiming for the highest numbers. Warren offered to let Bill go first, but this made Bill suspicious so he opted to go second. It turned out to be a wise choice: these were intransitive dice. The first die had an advantage when rolling against the second, the second had an advantage when rolling against the third, but the first did not have an advantage when rolling against the third!

To formalize this: define a “die” as any shape with at least one face such that each face shows a positive integer. When a die is rolled, one of its faces is selected uniformly at random. When two dice roll against each other, the die whose selected face shows a higher number earns 11 point; if both numbers are equal, each die earns 12\frac{1}{2} points. For dice DD and D′D' , define score(D,D′)score(D, D' ) as the expected number of points DD earns from a single roll against D′D'. If score(D,D′)>12score(D, D') > \frac{1}{2}, we say that DD has an advantage over D′D'; if score(D,D′)=12score(D, D') = \frac{1}{2}, the two dice are tied. For example, if DD is the first die in the sample input and D′D' is the second, score(D,D′)=49score(D, D') = \frac{4}{9} and score(D′,D)=59score(D' , D) = \frac{5}{9}, so D′D' has an advantage over DD.

Given two dice D_1D\_1 and D_2D\_2 such that D_1D\_1 has an advantage over D_2D\_2, you want a third die D_3D\_3 that forms an intransitive trio with the other two. Among all D_3D\_3 that have an advantage over or tie with D_1D\_1, compute the lowest possible score(D_3,D_2)score(D\_3, D\_2). If this is less than 12\frac{1}{2}, you can make an intransitive trio! Similarly, among all D_3D\_3 such that D_2D\_2 has an advantage over or ties with D_3D\_3, compute the highest possible score(D_3,D_1)score(D\_3, D\_1).

입력

The input contains two lines, each describing one die. One of the dice (the first or the second) has an advantage over the other. The die with the advantage is D_1D\_1 and the other is D_2D\_2.

The first integer on a line gives nn (1≤n≤1051 ≤ n ≤ 10^5), the number of faces on the die. Then follow nn integers f_if\_i (1≤f_i≤1091 ≤ f\_i ≤ 10^9 for each 1≤i≤n1 ≤ i ≤ n), giving the integer on each face.

출력

Output one line containing the lowest score(D_3,D_2)score(D\_3, D\_2) and the highest score(D_3,D_1)score(D\_3, D\_1) under the above conditions. The two scores do not need to use the same die D_3D\_3. Your answer should have an absolute error of at most 10−610^{-6}.

예제2

  1. 예제 1

    입력
    6 1 1 6 6 8 8
    3 2 4 9
    
    예상 출력
    0.291666667 0.750000000
    
  2. 예제 2

    입력
    4 9 3 7 5
    3 4 2 3
    
    예상 출력
    0.500000000 0.500000000