daily pastebin goal
73%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. inputl = sys.stdin.read().strip().split("\n")
  4. totaldistance = int(inputl.pop(0))
  5.  
  6. currenttime = 0
  7. current_distance = 0
  8.  
  9. light_position = 0
  10.  
  11. for light in inputl:
  12.     light_position, red, green = [int(x) for x in light.split()]
  13.  
  14.     currenttime += light_position - current_distance
  15.     current_distance = light_position
  16.  
  17.     cycle_currenttime = red + green
  18.     currenttime_relative_to_cycle = cycle_currenttime - \
  19.         (currenttime % cycle_currenttime)
  20.     if currenttime_relative_to_cycle - green > 0:
  21.         currenttime += currenttime_relative_to_cycle - green
  22. currenttime += totaldistance - light_position
  23.  
  24.  
  25. print(currenttime)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top