fork download
  1. def parse(inFile):
  2. n = inFile.getInt()
  3. vines = [inFile.getInts() for k in xrange(n)]
  4. dist = inFile.getInt()
  5. return (n, vines, dist)
  6.  
  7. def solve((n, vines, dist)):
  8. best = [-1] * n
  9. best[0] = 0
  10. j = 1
  11. for i in xrange(n):
  12. if best[i] != -1:
  13. reach = vines[i][0] + min(vines[i][1], vines[i][0] - best[i])
  14. if reach >= dist:
  15. return "YES"
  16. while (j < n) and (vines[j][0] <= reach):
  17. best[j] = vines[i][0]
  18. j += 1
  19. return "NO"
  20.  
  21. if __name__ == "__main__":
  22. from GCJ import GCJ
  23. GCJ(parse, solve, "/Users/lpebody/gcj/2012_2/a/", "A").run()
  24.  
  25.  
  26.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty