Bhavit and Valentines Day
All submissions for this problem are available.
It's Valentines day and, Bhavit is roaming with his girlfriend at their Collge's fest Arena. They happen to stumble upon the FunGames stalls. There is one particular game on that stall that catches his girlfriend's fancy. Being a curious mind that she is, she thinks that the game is impossible to win at and poses a challenge to Bhavit. She promises Bhavit kisses if he wins the game else she'll break up.
In the game there are B distinct boxes. Also there are various balls of n different colors named from 0,1,2...n-1. At first, Bhavit has to distribute the balls in boxes. Then his girlfriend has to randomly choose a box and then randomly select a ball from that box. If the ball is of color 0 , then she'll win and Bhavit will get kisses.
Help Bhavit in distributing the balls in boxes in such a way that it maximizes his girlfriend's chance of drawing a ball of color 0 so that he gets kisses and then, tell the probablity that the ball his girlfriend draws is the ball of color 0.
Bhavit can put any number of balls of any color in any box
If the girlfriend chooses an empty Box, that will mean she didn't find a ball of color '0' in that box
First line contains B, total boxes
Second line contains n, total colors of balls
The next line contains n space seperated integers ci where 0 ≤ i ≤ n - 1 denoting total balls of color i.
The only line of output should contain the probablity of drawing ball of color 0 as mentioned in problem description
Your output will be considered correct if it's absolute error is < 10-6
- 1 ≤ B ≤ 105
- .1 ≤ n ≤ 105
- .1 ≤ ci ≤ 104
Input: 2 2 1 1 Output: 0.500000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions