def parse(inFile):
[X,S,R,t,N] = inFile.getInts()
return (X,S,R,t,[inFile.getInts() for k in xrange(N)])
def solve((length,walkSpeed,runSpeed,time,walkways)):
walkways = [[w,E-B] for [B,E,w] in walkways]
walkways += [[0,length-sum([z[1] for z in walkways])]]
walkways.sort()
timeTaken = 0
for [speed,length] in walkways:
runtime = float(length) / (runSpeed + speed)
if (runtime < time):
time -= runtime
timeTaken += runtime
else:
walktime = float(length - (runSpeed + speed) * time) / (walkSpeed + speed)
timeTaken += time + walktime
time = 0
return "%.7f" % timeTaken
if __name__ == "__main__":
from GCJ import GCJ
GCJ(parse, solve, "/Users/lpebody/gcj/2011_round2/", "a").run()
ZGVmIHBhcnNlKGluRmlsZSk6CiAgICBbWCxTLFIsdCxOXSA9IGluRmlsZS5nZXRJbnRzKCkKICAgIHJldHVybiAoWCxTLFIsdCxbaW5GaWxlLmdldEludHMoKSBmb3IgayBpbiB4cmFuZ2UoTildKQoKZGVmIHNvbHZlKChsZW5ndGgsd2Fsa1NwZWVkLHJ1blNwZWVkLHRpbWUsd2Fsa3dheXMpKToKICAgIHdhbGt3YXlzID0gW1t3LEUtQl0gZm9yIFtCLEUsd10gaW4gd2Fsa3dheXNdCiAgICB3YWxrd2F5cyArPSBbWzAsbGVuZ3RoLXN1bShbelsxXSBmb3IgeiBpbiB3YWxrd2F5c10pXV0KICAgIHdhbGt3YXlzLnNvcnQoKQogICAgdGltZVRha2VuID0gMAogICAgZm9yIFtzcGVlZCxsZW5ndGhdIGluIHdhbGt3YXlzOgogICAgICAgIHJ1bnRpbWUgPSBmbG9hdChsZW5ndGgpIC8gKHJ1blNwZWVkICsgc3BlZWQpCiAgICAgICAgaWYgKHJ1bnRpbWUgPCB0aW1lKToKICAgICAgICAgICAgdGltZSAtPSBydW50aW1lCiAgICAgICAgICAgIHRpbWVUYWtlbiArPSBydW50aW1lCiAgICAgICAgZWxzZToKICAgICAgICAgICAgd2Fsa3RpbWUgPSBmbG9hdChsZW5ndGggLSAocnVuU3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