B. Andrey and Problem
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with
a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.

Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of
Andrey not getting upset.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) —
the number of Andrey's friends. The second line contains n real numbers pi(0.0 ≤ pi ≤ 1.0) —
the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point.

Output

Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9.

Sample test(s)
input
4
0.1 0.2 0.3 0.8
output
0.800000000000
input
2
0.1 0.2
output
0.260000000000
Note

In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one.

In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.


Codeforces Round #253 (Div. 1) B. Andrey and Problem的更多相关文章

  1. Codeforces Round #253 (Div. 2) D. Andrey and Problem

    关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...

  2. Codeforces Round 253 (Div. 2)

    layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  3. Codeforces Round #253 (Div. 1) (A, B, C)

    Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...

  4. Codeforces Round #253 (Div. 2) D题

    题目大意是选出一个其他不选,问问最大概率: 刚开始想到DP:F[I][J][0]:表示从 前I个中选出J个的最大值, 然后对于F[I][J][1]=MAX(F[I-1][J][1],F[I-1][J- ...

  5. Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力

    A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...

  6. Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat

    本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...

  7. Codeforces Round #253 (Div. 2) A. Anton and Letters

    题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...

  8. Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】

    简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include < ...

  9. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

随机推荐

  1. 状态压缩动态规划 -- 棋盘问题 POJ 1321

    一个 N * N 的棋盘上面,有些格子不能放,放置 M 的棋子, 每两个棋子不能在同一行或者同一列,问有多少种放法 DFS太慢,用SCR好点点 Python 仅仅有 22 行,事实上能够更短.可是得排 ...

  2. javascript启示录英文单词生词

    odd:奇怪的 represent:代表 primitive:原始的 trivial:平凡的 demonstrate:证明 keep this at the forefront of your min ...

  3. __NSAutoreleaseNoPool(): ... utoreleased with no pool in place - just leaking

    __NSAutoreleaseNoPool(): ... utoreleased with no pool in place - just leaking 我的平台 mac os 10.6 Xcode ...

  4. NET Core RC2

    .NET Core RC2/RTM 明确了时间表 .NET Core 经过了将近2年的开发,去年12月份发布的RC1版本,明确来说那只是一个beta版本,自从RC1发布以来,看到github里的RC2 ...

  5. STM32M CUBE实现printf打印调试信息以及实现单字节接收

    在写单片机程序时我们一般喜欢使用printf来通过串口打印调试信息,但这个函数是不能够直接使用的.必须做点对库函数的修改. 具体project下载地址: http://download.csdn.ne ...

  6. Linux温馨提示1--安装U板块和Windwos划分

    一.安装U盘 现在我用Ubuntu12.04在插入U光盘将被直接安装到/media/下, 10:33linc@Linc-Ubuntu:linc$ df -h Filesystem Size Used ...

  7. Uva - 11419 - SAM I AM

    题意:一个矩形——R*C的网格,在某些位置上有石头,在网格外开一炮可以打掉该行或者该列的石头,求打掉这些石头最少需要多少门大炮,位置分别设在哪行哪列(0<R<1001, 0 < C ...

  8. Config File Settings Of EF——实体框架的配置文件设置

    我亦MSDN 原文地址 http://msdn.microsoft.com/en-us/data/jj556606 Entity Framework allows a number of settin ...

  9. Twenty Newsgroups Classification任务之二seq2sparse(5)

    接上篇blog,继续分析.接下来要调用代码如下: // Should document frequency features be processed if (shouldPrune || proce ...

  10. HTML5 Canvas动画效果实现原理

    在线演示 使用HTML5画布可以帮助我们高速实现简单的动画效果.基本原理例如以下: 每隔一定时间绘制图形而且清除图形,用来模拟出一个动画过程,能够使用context.clearRect(0, 0, x ...