CF626D.Jerry's Protest

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry draw randomly without replacement from a jar containing n balls, each labeled with a distinct positive integer. Without looking, they hand their balls to Harry, who awards the point to the player with the larger number and returns the balls to the jar. The winner of the game is the one who wins at least two of the three rounds.

Andrew wins rounds 1 and 2 while Jerry wins round 3, so Andrew wins the game. However, Jerry is unhappy with this system, claiming that he will often lose the match despite having the higher overall total. What is the probability that the sum of the three balls Jerry drew is strictly higher than the sum of the three balls Andrew drew?

安德鲁和杰瑞正在与哈利一起玩游戏,哈利担任记分员。游戏共进行三轮。每轮中,安德鲁和杰瑞从一个装有 nn 个球的罐子中不放回地随机抽取一个球,每个球上标有一个互不相同的正整数。他们不看球上的数字,直接将球交给哈利;哈利比较两个数字的大小,将该轮分数判给数字较大的一方,并将两个球放回罐中。游戏的胜者是三轮中至少赢得两轮的人。

已知安德鲁赢得了第 1 轮和第 2 轮,杰瑞赢得了第 3 轮,因此安德鲁赢得整场游戏。然而,杰瑞对这一规则感到不满,声称:尽管自己三轮所抽球的数字总和更高,却仍常常输掉比赛。那么,杰瑞所抽三个球的数字之和严格大于安德鲁所抽三个球的数字之和的概率是多少?

输入格式

The first line of input contains a single integer n (2 ≤ n ≤ 2000) — the number of balls in the jar.

The second line contains n integers a__i (1 ≤ a__i ≤ 5000) — the number written on the _i_th ball. It is guaranteed that no two balls have the same number.

输入的第一行包含一个整数 nn(2≤n≤20002 \leq n \leq 2000)—— 表示罐子中球的数量。

第二行包含 nn 个整数 aia_i(1≤ai≤50001 \leq a_i \leq 5000)—— 表示第 ii 个球上所写的数字。保证任意两个球上的数字互不相同。

输出格式

Print a single real value — the probability that Jerry has a higher total, given that Andrew wins the first two rounds and Jerry wins the third. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

输出一个实数值——即在安德鲁赢得前两轮且杰瑞赢得第三轮的前提下,杰瑞总分更高的概率。若你的答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

具体而言:假设你的答案为 aa,评测组的标准答案为 bb。当满足 时,评测程序将判定你的答案正确。

输入输出样例

  • 输入#1

    2
    1 2

    输出#1

    0.0000000000
  • 输入#2

    3
    1 2 10

    输出#2

    0.0740740741

说明/提示

In the first case, there are only two balls. In the first two rounds, Andrew must have drawn the 2 and Jerry must have drawn the 1, and vice versa in the final round. Thus, Andrew's sum is 5 and Jerry's sum is 4, so Jerry never has a higher total.

In the second case, each game could've had three outcomes — 10 - 2, 10 - 1, or 2 - 1. Jerry has a higher total if and only if Andrew won 2 - 1 in both of the first two rounds, and Jerry drew the 10 in the last round. This has probability .

第一种情况中,仅有两个球。在前两轮中,安德鲁必定抽到了2,杰瑞必定抽到了1;而在最后一轮中情况相反。因此,安德鲁的总和为5,杰瑞的总和为4,故杰瑞的总和永远不会更高。

第二种情况中,每局比赛可能有三种结果:10 - 2、10 - 1 或 2 - 1。杰瑞的总和更高当且仅当安德鲁在前两轮均以2 - 1获胜,且杰瑞在最后一轮抽到了10。该事件发生的概率为 。

输入解题思路,AI测评打分。不知道怎么写?

首页