Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- robots_info = input().split(';')
- start_time = list(map(int, input().split(':')))
- time = sum([start_time[0]*60*60, start_time[1]*60, start_time[2]])
- robots = {}
- new_robots = {}
- products = deque()
- def get_time(t: int):
- seconds = t % 60
- hours = (t // 60) // 60
- minutes = (t // 60) - hours * 60
- seconds_print = f'0{seconds}'if seconds < 10 else seconds
- minutes_print = f'0{minutes}' if minutes < 10 else minutes
- hours_print = f'0{hours}' if hours < 10 else hours
- return f'{hours_print}:{minutes_print}:{seconds_print}'
- while True:
- command = input()
- if command == 'End':
- break
- product = command
- products.append(product)
- for x in robots_info:
- key, value = x.split('-')
- robots.update({key: [int(value), time + robots_info.index(x) +1, 0]})
- update = False
- while True:
- product = products[0]
- if robots:
- robot = [x for x in list(robots) if robots[x][2] == 0]
- if robot:
- robot = robot[0]
- print(f'{robot} - {product} [{get_time(robots[robot][1])}]')
- new_robots.update({robot: robots[robot]})
- del robots[robot]
- products.popleft()
- if not products:
- break
- else:
- products.append(products.popleft())
- for x in new_robots:
- new_robots[x][1] += 1
- new_robots[x][2] += 1
- if new_robots[x][1] == 86400:
- new_robots[x][1] = 0
- if new_robots[x][2] == new_robots[x][0]:
- new_robots[x][2] = 0
- robots.update({x: new_robots[x]})
- update = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement