def parse(inFile):
[A, B] = inFile.getInts()
return (A, B, inFile.getFloats())
def solve((A, B, probs)):
rec = 2 + B
prob = 1.0
for i in xrange(A + 1):
if (i > 0):
prob = prob * probs[i-1]
score = (A + B + 1 - (2 * i)) + (1 - prob) * (B + 1)
if (score < rec):
rec = score
return "%.7f" % rec
if __name__ == "__main__":
from GCJ import GCJ
GCJ(parse, solve, "/Users/lpebody/gcj/2012_1a/", "a").run()
ZGVmIHBhcnNlKGluRmlsZSk6CiAgICBbQSwgQl0gPSBpbkZpbGUuZ2V0SW50cygpCiAgICByZXR1cm4gKEEsIEIsIGluRmlsZS5nZXRGbG9hdHMoKSkKCmRlZiBzb2x2ZSgoQSwgQiwgcHJvYnMpKToKICAgIHJlYyA9IDIgKyBCCiAgICBwcm9iID0gMS4wCiAgICBmb3IgaSBpbiB4cmFuZ2UoQSArIDEpOgogICAgICAgIGlmIChpID4gMCk6CiAgICAgICAgICAgIHByb2IgPSBwcm9iICogcHJvYnNbaS0xXQogICAgICAgIHNjb3JlID0gKEEgKyBCICsgMSAtICgyICogaSkpICsgKDEgLSBwcm9iKSAqIChCICsgMSkKICAgICAgICBpZiAoc2NvcmUgPCByZWMpOgogICAgICAgICAgICByZWMgPSBzY29yZQogICAgcmV0dXJuICIlLjdmIiAlIHJlYwoKaWYgX19uYW1lX18gPT0gIl9fbWFpbl9fIjoKICAgIGZyb20gR0NKIGltcG9ydCBHQ0oKICAgIEdDSihwYXJzZSwgc29sdmUsICIvVXNlcnMvbHBlYm9keS9nY2ovMjAxMl8xYS8iLCAiYSIpLnJ1bigpCgogICAgICAgICAgICAK