def parse(inFile):
[D,N,A] = inFile.getWords()
dists = [inFile.getFloats() for k in xrange(int(N))]
accs = inFile.getFloats()
return (float(D), dists, accs)
from math import sqrt
def solveInternal((D, dists, accs)):
if (dists[0][1] >= D):
return [sqrt(2 * D / acc) for acc in accs]
d0 = max([(z[1],z[0]) for z in dists if z[1] < D])
d1 = min([(z[1],z[0]) for z in dists if z[1] >= D])
T = d0[1] + ((D - d0[0]) * (d1[1] - d0[1])) / (d1[0] - d0[0])
dists = [z for z in dists if z[1] < D] + [(T,D)]
answers = []
for a in accs:
timeToWait = max([0.0] + [t-sqrt(2 * x / a) for [t,x] in dists])
answers += [timeToWait + sqrt(2 * D / a)]
return answers
def solve(x):
ans = solveInternal(x)
return "\n".join([""]+[str(z) for z in ans])
if __name__ == "__main__":
from GCJ import GCJ
GCJ(parse, solve, "/Users/lpebody/gcj/setup/", "b").run()
ZGVmIHBhcnNlKGluRmlsZSk6CiAgICBbRCxOLEFdID0gaW5GaWxlLmdldFdvcmRzKCkKICAgIGRpc3RzID0gW2luRmlsZS5nZXRGbG9hdHMoKSBmb3IgayBpbiB4cmFuZ2UoaW50KE4pKV0KICAgIGFjY3MgPSBpbkZpbGUuZ2V0RmxvYXRzKCkKICAgIHJldHVybiAoZmxvYXQoRCksIGRpc3RzLCBhY2NzKQoKZnJvbSBtYXRoIGltcG9ydCBzcXJ0CgpkZWYgc29sdmVJbnRlcm5hbCgoRCwgZGlzdHMsIGFjY3MpKToKICAgIGlmIChkaXN0c1swXVsxXSA+PSBEKToKICAgICAgICByZXR1cm4gW3NxcnQoMiAqIEQgLyBhY2MpIGZvciBhY2MgaW4gYWNjc10KICAgIGQwID0gbWF4KFsoelsxXSx6WzBdKSBmb3IgeiBpbiBkaXN0cyBpZiB6WzFdIDwgRF0pCiAgICBkMSA9IG1pbihbKHpbMV0selswXSkgZm9yIHogaW4gZGlzdHMgaWYgelsxXSA+PSBEXSkKICAgIFQgPSBkMFsxXSArICgoRCAtIGQwWzBdKSAqIChkM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