CF739E.Gosha is hunting

NOI/NOI+/CTSC

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Gosha is hunting. His goal is to catch as many Pokemons as possible. Gosha has a Poke Balls and b Ultra Balls. There are n Pokemons. They are numbered 1 through n. Gosha knows that if he throws a Poke Ball at the i-th Pokemon he catches it with probability p__i. If he throws an Ultra Ball at the i-th Pokemon he catches it with probability u__i. He can throw at most one Ball of each type at any Pokemon.

The hunting proceeds as follows: at first, Gosha chooses no more than a Pokemons at which he will throw Poke Balls and no more than b Pokemons at which he will throw Ultra Balls. After that, he throws the chosen Balls at the chosen Pokemons. If he throws both Ultra Ball and Poke Ball at some Pokemon, he is caught if and only if he is caught by any of these Balls. The outcome of a throw doesn't depend on the other throws.

Gosha would like to know what is the expected number of the Pokemons he catches if he acts in an optimal way. In other words, he would like to know the maximum possible expected number of Pokemons can catch.

戈沙正在捕猎宝可梦。他的目标是尽可能多地捕获宝可梦。戈沙拥有 aa 个精灵球(Poke Ball)和 bb 个超级球(Ultra Ball)。一共有 nn 只宝可梦,编号为 11 到 nn。戈沙知道:若他向第 ii 只宝可梦投掷一个精灵球,则捕获它的概率为 pip_i;若投掷一个超级球,则捕获它的概率为 uiu_i。他对每只宝可梦最多只能投掷每种球各一个。

捕猎过程如下:首先,戈沙选择至多 aa 只宝可梦向其投掷精灵球,同时选择至多 bb 只宝可梦向其投掷超级球(这两组选择可以有重叠)。随后,他将选定的球投向选定的宝可梦。若对某只宝可梦同时投掷了精灵球和超级球,则该宝可梦被捕获当且仅当它被其中至少一个球捕获。每次投掷的结果相互独立。

戈沙希望知道自己以最优策略行动时,所能捕获的宝可梦数量的期望值是多少。换言之,他希望求出所能达到的最大期望捕获数量。

输入格式

The first line contains three integers n, a and b (2 ≤ n ≤ 2000, 0 ≤ a, b ≤ n) — the number of Pokemons, the number of Poke Balls and the number of Ultra Balls.

The second line contains n real values _p_1, _p_2, ..., p__n (0 ≤ p__i ≤ 1), where p__i is the probability of catching the i-th Pokemon if Gosha throws a Poke Ball to it.

The third line contains n real values _u_1, _u_2, ..., u__n (0 ≤ u__i ≤ 1), where u__i is the probability of catching the i-th Pokemon if Gosha throws an Ultra Ball to it.

All the probabilities are given with exactly three digits after the decimal separator.

第一行包含三个整数 nn、aa 和 bb(2 ≤ n ≤ 20002 \leq n \leq 2000,0 ≤ a, b ≤ n0 \leq a, b \leq n)——分别表示宝可梦的数量、精灵球的数量以及超级球的数量。

第二行包含 nn 个实数 p1, p2, ..., pnp_1,\,p_2,\,...,\,p_n(0 ≤ pi ≤ 10 \leq p_i \leq 1),其中 pip_i 表示 Gosha 向第 ii 只宝可梦投掷一个精灵球时成功捕获它的概率。

第三行包含 nn 个实数 u1, u2, ..., unu_1,\,u_2,\,...,\,u_n(0 ≤ ui ≤ 10 \leq u_i \leq 1),其中 uiu_i 表示 Gosha 向第 ii 只宝可梦投掷一个超级球时成功捕获它的概率。

所有概率均精确给出小数点后三位。

输出格式

Print the maximum possible expected number of Pokemons Gosha can catch. The answer is considered correct if it's absolute or relative error doesn't exceed 10 - 4.

输出戈沙最多能捕获的宝可梦的期望数量。若答案的绝对或相对误差不超过 10−410^{-4},则视为正确。

输入输出样例

  • 输入#1

    3 2 2
    1.000 0.000 0.500
    0.000 1.000 0.500

    输出#1

    2.75
  • 输入#2

    4 1 3
    0.100 0.500 0.500 0.600
    0.100 0.500 0.900 0.400

    输出#2

    2.16
  • 输入#3

    3 2 0
    0.412 0.198 0.599
    0.612 0.987 0.443

    输出#3

    1.011

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

首页