fork(2) download
  1. def parse(inFile):
  2. [D,N,A] = inFile.getWords()
  3. dists = [inFile.getFloats() for k in xrange(int(N))]
  4. accs = inFile.getFloats()
  5. return (float(D), dists, accs)
  6.  
  7. from math import sqrt
  8.  
  9. def solveInternal((D, dists, accs)):
  10. if (dists[0][1] >= D):
  11. return [sqrt(2 * D / acc) for acc in accs]
  12. d0 = max([(z[1],z[0]) for z in dists if z[1] < D])
  13. d1 = min([(z[1],z[0]) for z in dists if z[1] >= D])
  14. T = d0[1] + ((D - d0[0]) * (d1[1] - d0[1])) / (d1[0] - d0[0])
  15. dists = [z for z in dists if z[1] < D] + [(T,D)]
  16. answers = []
  17. for a in accs:
  18. timeToWait = max([0.0] + [t-sqrt(2 * x / a) for [t,x] in dists])
  19. answers += [timeToWait + sqrt(2 * D / a)]
  20. return answers
  21.  
  22. def solve(x):
  23. ans = solveInternal(x)
  24. return "\n".join([""]+[str(z) for z in ans])
  25.  
  26. if __name__ == "__main__":
  27. from GCJ import GCJ
  28. GCJ(parse, solve, "/Users/lpebody/gcj/setup/", "b").run()
  29.  
  30.  
  31.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty