Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def status(red, green, time):
- if time < red:
- a = ['Red', red - time]
- return a
- else:
- i = 0
- j = 0
- while i < time:
- if j % 2 == 0:
- i += red
- else:
- i += green
- j += 1
- if j % 2 == 0:
- a = ['Green']
- else:
- a = ['Red', i - time]
- return a
- def main():
- s = sys.stdin.read().strip().split()
- L = int(s[0])
- D = [int(s[i]) for i in range(len(s)) if i % 3 == 1]
- R = [int(s[i]) for i in range(len(s)) if i % 3 == 2]
- G = [int(s[i]) for i in range(1, len(s)) if i % 3 == 0]
- time = 0
- distance = 0
- j = 0
- while distance < L:
- if distance not in D:
- distance += 1
- time += 1
- else:
- if status(R[j], G[j], time)[0] == 'Green':
- distance += 1
- time += 1
- elif status(R[j], G[j], time)[0] == 'Red':
- time += status(R[j], G[j], time)[1]
- distance += 1
- time += 1
- j += 1
- print(time)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement