fork(87) download
  1. def parse(inFile):
  2. [X,S,R,t,N] = inFile.getInts()
  3. return (X,S,R,t,[inFile.getInts() for k in xrange(N)])
  4.  
  5. def solve((length,walkSpeed,runSpeed,time,walkways)):
  6. walkways = [[w,E-B] for [B,E,w] in walkways]
  7. walkways += [[0,length-sum([z[1] for z in walkways])]]
  8. walkways.sort()
  9. timeTaken = 0
  10. for [speed,length] in walkways:
  11. runtime = float(length) / (runSpeed + speed)
  12. if (runtime < time):
  13. time -= runtime
  14. timeTaken += runtime
  15. else:
  16. walktime = float(length - (runSpeed + speed) * time) / (walkSpeed + speed)
  17. timeTaken += time + walktime
  18. time = 0
  19. return "%.7f" % timeTaken
  20.  
  21. if __name__ == "__main__":
  22. from GCJ import GCJ
  23. GCJ(parse, solve, "/Users/lpebody/gcj/2011_round2/", "a").run()
  24.  
  25.  
  26.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty